12#ifndef SST_CORE_SERIALIZATION_IMPL_SERIALIZE_UTILITY_H
13#define SST_CORE_SERIALIZATION_IMPL_SERIALIZE_UTILITY_H
15#ifndef SST_INCLUDING_SERIALIZE_H
17 "The header file sst/core/serialization/impl/serialize_utility.h should not be directly included as it is not part of the stable public API. The file is included in sst/core/serialization/serialize.h"
20#include "sst/core/sst_complex.h"
29namespace SST::Core::Serialization {
34template <
template <
class...>
class,
template <
class...>
class>
35constexpr bool is_same_template_v =
false;
37template <
template <
class...>
class T>
38constexpr bool is_same_template_v<T, T> =
true;
40template <
template <
class...>
class T1,
template <
class...>
class T2>
41using is_same_template = std::bool_constant<is_same_template_v<T1, T2>>;
46template <
class,
template <
class...>
class>
47constexpr bool is_same_type_template_v =
false;
49template <
template <
class...>
class T1,
class... T1ARGS,
template <
class...>
class T2>
50constexpr bool is_same_type_template_v<T1<T1ARGS...>, T2> = is_same_template_v<T1, T2>;
52template <
class T,
template <
class...>
class TT>
53using is_same_type_template = std::bool_constant<is_same_type_template_v<T, TT>>;
58#if __cplusplus < 202002l
61constexpr bool is_unbounded_array_v =
false;
64constexpr bool is_unbounded_array_v<T[]> =
true;
67using is_unbounded_array = std::bool_constant<is_unbounded_array_v<T>>;
71using std::is_unbounded_array;
72using std::is_unbounded_array_v;
80template <
class,
class =
void>
97constexpr bool has_serialize_order_v = has_serialize_order<T>::value;
102namespace pvt_nfields {
114template <
class C,
class,
bool = std::is_aggregate_v<C>,
class = C>
115constexpr bool nfields_ge_impl =
false;
119template <
class C,
size_t... I>
120constexpr bool nfields_ge_impl<C, std::index_sequence<I...>,
true,
decltype(C { (I,
glob())... })> =
true;
123template <
class C,
size_t N>
124constexpr bool nfields_ge = nfields_ge_impl<C, std::make_index_sequence<N>>;
127template <
class C,
size_t L,
size_t H,
size_t M = L + (H - L) / 2,
bool = M != L>
128constexpr size_t b_search = L;
131template <
class C,
size_t L,
size_t H,
size_t M,
bool>
132constexpr size_t b_search_next = b_search<C, L, M>;
135template <
class C,
size_t L,
size_t H,
size_t M>
136constexpr size_t b_search_next<C, L, H, M, true> = b_search<C, M, H>;
139template <
class C,
size_t L,
size_t H,
size_t M>
140constexpr size_t b_search<C, L, H, M, true> = b_search_next<C, L, H, M, nfields_ge<C, M>>;
143template <
class C,
size_t N = 1,
bool = true>
144constexpr size_t nfields = nfields<C, N * 2, nfields_ge<C, N * 2>>;
147template <
class C,
size_t N>
148constexpr size_t nfields<C, N, false> = b_search<C, 0, N>;
154constexpr size_t nfields = pvt_nfields::nfields<C>;
190namespace pvt_trivial {
194template <
class C,
bool = std::conjunction_v<std::is_aggregate<C>, std::is_trivially_copyable<C>,
195 std::is_standard_layout<C>, std::negation<has_serialize_order<C>>>>
196constexpr bool is_trivially_serializable_v =
197 complex_properties<C>::is_complex ||
198 std::disjunction_v<std::is_arithmetic<C>, std::is_enum<C>, std::is_member_object_pointer<C>>;
204 template <
class C,
class = std::enable_if_t<is_trivially_serializable_v<C>>>
209template <
class C,
class,
class = C>
210constexpr bool has_ts_fields =
false;
214template <
class C,
size_t... I>
215constexpr bool has_ts_fields<C, std::index_sequence<I...>,
decltype(C { (I,
glob_ts())... })> =
true;
219constexpr bool is_trivially_serializable_v<C, true> = has_ts_fields<C, std::make_index_sequence<nfields<C>>>;
223constexpr bool is_trivially_serializable_v<std::bitset<N>,
false> =
true;
228inline constexpr bool is_trivially_serializable_v<_Float16, false> =
true;
232#ifdef __SIZEOF_INT128__
234inline constexpr bool is_trivially_serializable_v<__int128, false> =
true;
237inline constexpr bool is_trivially_serializable_v<unsigned __int128, false> =
true;
244constexpr bool is_trivially_serializable_v = pvt_trivial::is_trivially_serializable_v<C>;
247using is_trivially_serializable = std::bool_constant<is_trivially_serializable_v<C>>;
Definition serialize_utility.h:82
Definition serialize_utility.h:107
Definition serialize_utility.h:202