12#ifndef SST_CORE_SERIALIZATION_IMPL_GET_ARRAY_SIZE_H
13#define SST_CORE_SERIALIZATION_IMPL_GET_ARRAY_SIZE_H
15#ifndef SST_INCLUDING_SERIALIZER_H
17 "The header file sst/core/serialization/impl/get_array_size.h should not be directly included as it is not part of the stable public API. The file is included in sst/core/serialization/serializer.h"
24namespace SST::Core::Serialization {
27template <
typename SIZE_T>
28std::enable_if_t<std::is_integral_v<SIZE_T>,
size_t>
29get_array_size(SIZE_T size,
const char* msg)
32 if constexpr ( std::is_unsigned_v<SIZE_T> )
33 range_error = size > SIZE_MAX;
34 else if constexpr (
sizeof(SIZE_T) >
sizeof(size_t) )
35 range_error = size < 0 || size >
static_cast<SIZE_T
>(SIZE_MAX);
37 range_error = size < 0;
38 if ( range_error )
throw std::range_error(msg);
39 return static_cast<size_t>(size);