13 #ifndef __UT_SMALLARRAY_H_INCLUDED__
14 #define __UT_SMALLARRAY_H_INCLUDED__
28 template <
typename T,
size_t MAX_BYTES = 64>
32 enum { MAX_ELEMS = MAX_BYTES/
sizeof(
T) < 1 ? 1 : MAX_BYTES/
sizeof(
T) };
39 #if !defined(__clang__) && defined(_MSC_VER)
40 #define UT_SMALL_ARRAY_SIZE_ASSERT() \
41 using ThisT = UT_SmallArray<T,MAX_BYTES>; \
42 SYS_STATIC_ASSERT(offsetof(ThisT, myBuffer) == sizeof(UT_Array<T>))
44 #define UT_SMALL_ARRAY_SIZE_ASSERT() \
45 UT_ASSERT_P(!UT_Array<T>::isHeapBuffer());
101 #undef UT_SMALL_ARRAY_SIZE_ASSERT
142 alignas(
T)
char myBuffer[MAX_ELEMS*
sizeof(T)];
148 template <
typename T>
149 struct DefaultClearer;
151 template <
typename T,
size_t BYTES>
159 p->~UT_SmallArray<
T, BYTES>();
170 static const bool clearNeedsDestruction =
false;
177 template <
typename T>
180 #endif // __UT_SMALLARRAY_H_INCLUDED__
#define UT_SMALL_ARRAY_SIZE_ASSERT()
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
UT_Array< T > & operator=(const UT_Array< T > &a)
UT_SmallArray(const UT_Array< T > ©)
static void clearConstruct(UT_SmallArray< T, BYTES > *p)
static constexpr struct UT_ArrayCT::ExternalCapacity EXTERNAL_CAPACITY
static void clear(UT_SmallArray< T, BYTES > &v)
UT_SmallArray(UT_Array< T > &&movable) noexcept
#define SYS_DECLARE_IS_NOT_TR_TEMPLATE(...)
Version for class template.
static constexpr struct UT_ArrayCT::ExternalMove EXTERNAL_MOVE
UT_SmallArray()
Default construction.
static bool isClear(const UT_SmallArray< T, BYTES > &v)
UT_SmallArray(const UT_SmallArray ©)
bool isEmpty() const
Returns true iff there are no occupied elements in the array.