@@ -64,6 +64,13 @@ template <typename T>
6464class MakeGarbageCollectedTraitBase
6565 : private internal::MakeGarbageCollectedTraitInternal {
6666 private:
67+ static_assert (internal::IsGarbageCollectedType<T>::value,
68+ " T needs to be a garbage collected object" );
69+ static_assert (!IsGarbageCollectedWithMixinTypeV<T> ||
70+ sizeof (T) <=
71+ internal::api_constants::kLargeObjectSizeThreshold ,
72+ " GarbageCollectedMixin may not be a large object" );
73+
6774 template <typename U, typename CustomSpace>
6875 struct SpacePolicy {
6976 static void * Allocate (AllocationHandle& handle, size_t size) {
@@ -153,12 +160,6 @@ class MakeGarbageCollectedTrait : public MakeGarbageCollectedTraitBase<T> {
153160 public:
154161 template <typename ... Args>
155162 static T* Call (AllocationHandle& handle, Args&&... args) {
156- static_assert (internal::IsGarbageCollectedType<T>::value,
157- " T needs to be a garbage collected object" );
158- static_assert (
159- !internal::IsGarbageCollectedMixinType<T>::value ||
160- sizeof (T) <= internal::api_constants::kLargeObjectSizeThreshold ,
161- " GarbageCollectedMixin may not be a large object" );
162163 void * memory =
163164 MakeGarbageCollectedTraitBase<T>::Allocate (handle, sizeof (T));
164165 T* object = ::new (memory) T (std::forward<Args>(args)...);
@@ -169,12 +170,6 @@ class MakeGarbageCollectedTrait : public MakeGarbageCollectedTraitBase<T> {
169170 template <typename ... Args>
170171 static T* Call (AllocationHandle& handle, AdditionalBytes additional_bytes,
171172 Args&&... args) {
172- static_assert (internal::IsGarbageCollectedType<T>::value,
173- " T needs to be a garbage collected object" );
174- static_assert (
175- !internal::IsGarbageCollectedMixinType<T>::value ||
176- sizeof (T) <= internal::api_constants::kLargeObjectSizeThreshold ,
177- " GarbageCollectedMixin may not be a large object" );
178173 void * memory = MakeGarbageCollectedTraitBase<T>::Allocate (
179174 handle, sizeof (T) + additional_bytes.value );
180175 T* object = ::new (memory) T (std::forward<Args>(args)...);
0 commit comments