Nugget
atomic_asserts.h
1 // Copyright (c) Electronic Arts Inc. All rights reserved.
4 
5 
6 #ifndef EASTL_ATOMIC_INTERNAL_STATIC_ASSERTS_H
7 #define EASTL_ATOMIC_INTERNAL_STATIC_ASSERTS_H
8 
9 #if defined(EA_PRAGMA_ONCE_SUPPORTED)
10  #pragma once
11 #endif
12 
13 
14 #define EASTL_ATOMIC_STATIC_ASSERT_VOLATILE_MEM_FN(type) \
15  static_assert(!eastl::is_same<type, type>::value, "eastl::atomic<T> : volatile eastl::atomic<T> is not what you expect! Read the docs in EASTL/atomic.h! Use the memory orders to access the atomic object!");
16 
17 #define EASTL_ATOMIC_STATIC_ASSERT_INVALID_MEMORY_ORDER(type) \
18  static_assert(!eastl::is_same<type, type>::value, "eastl::atomic<T> : invalid memory order for the given operation!");
19 
20 #define EASTL_ATOMIC_STATIC_ASSERT_TYPE(type) \
21  /* User Provided T must not be cv qualified */ \
22  static_assert(!eastl::is_const<type>::value, "eastl::atomic<T> : Template Typename T cannot be const!"); \
23  static_assert(!eastl::is_volatile<type>::value, "eastl::atomic<T> : Template Typename T cannot be volatile! Use the memory orders to access the underlying type for the guarantees you need."); \
24  /* T must satisfy StandardLayoutType */ \
25  static_assert(eastl::is_standard_layout<type>::value, "eastl::atomic<T> : Must have standard layout!"); \
26  /* T must be TriviallyCopyable but it does not have to be TriviallyConstructible */ \
27  static_assert(eastl::is_trivially_copyable<type>::value, "eastl::atomci<T> : Template Typename T must be trivially copyable!"); \
28  static_assert(eastl::is_copy_constructible<type>::value, "eastl::atomic<T> : Template Typename T must be copy constructible!"); \
29  static_assert(eastl::is_move_constructible<type>::value, "eastl::atomic<T> : Template Typename T must be move constructible!"); \
30  static_assert(eastl::is_copy_assignable<type>::value, "eastl::atomic<T> : Template Typename T must be copy assignable!"); \
31  static_assert(eastl::is_move_assignable<type>::value, "eastl::atomic<T> : Template Typename T must be move assignable!"); \
32  static_assert(eastl::is_trivially_destructible<type>::value, "eastl::atomic<T> : Must be trivially destructible!"); \
33  static_assert(eastl::internal::is_atomic_lockfree_size<type>::value, "eastl::atomic<T> : Template Typename T must be a lockfree size!");
34 
35 #define EASTL_ATOMIC_STATIC_ASSERT_TYPE_IS_OBJECT(type) \
36  static_assert(eastl::is_object<type>::value, "eastl::atomic<T> : Template Typename T must be an object type!");
37 
38 #define EASTL_ATOMIC_ASSERT_ALIGNED(alignment) \
39  EASTL_ASSERT((alignment & (alignment - 1)) == 0); \
40  EASTL_ASSERT((reinterpret_cast<uintptr_t>(this) & (alignment - 1)) == 0)
41 
42 
43 namespace eastl
44 {
45 
46 
47 namespace internal
48 {
49 
50 
51  template <typename T>
53  {
65  static_assert(!eastl::is_same<T, T>::value, "eastl::atomic<T> : invalid template type T!");
66  };
67 
68 
69 } // namespace internal
70 
71 
72 } // namespace eastl
73 
74 
75 #endif /* EASTL_ATOMIC_INTERNAL_STATIC_ASSERTS_H */
EA Standard Template Library.
Definition: algorithm.h:288
Definition: atomic_asserts.h:53
Definition: type_traits.h:604