diff --git a/components/nif/nifstream.hpp b/components/nif/nifstream.hpp index 92f8ca0f91..c3fc03320d 100644 --- a/components/nif/nifstream.hpp +++ b/components/nif/nifstream.hpp @@ -26,20 +26,16 @@ namespace Nif class Reader; - template - struct is_arithmetic - : std::integral_constant || std::is_same::value> - { - }; - template inline void readLittleEndianBufferOfType(Files::IStreamPtr& pIStream, T* dest) { - static_assert(is_arithmetic(), "Buffer element type is not arithmetic"); + static_assert( + std::is_arithmetic_v || std::is_same_v, "Buffer element type is not arithmetic"); + static_assert(!std::is_same_v, "Buffer element type is boolean"); pIStream->read((char*)dest, numInstances * sizeof(T)); if (pIStream->bad()) - throw std::runtime_error("Failed to read little endian typed (" + std::string(typeid(T).name()) - + ") buffer of " + std::to_string(numInstances) + " instances"); + throw std::runtime_error("Failed to read typed (" + std::string(typeid(T).name()) + ") buffer of " + + std::to_string(numInstances) + " instances"); if constexpr (Misc::IS_BIG_ENDIAN) for (std::size_t i = 0; i < numInstances; i++) Misc::swapEndiannessInplace(dest[i]); @@ -48,11 +44,13 @@ namespace Nif template inline void readLittleEndianDynamicBufferOfType(Files::IStreamPtr& pIStream, T* dest, std::size_t numInstances) { - static_assert(is_arithmetic(), "Buffer element type is not arithmetic"); + static_assert( + std::is_arithmetic_v || std::is_same_v, "Buffer element type is not arithmetic"); + static_assert(!std::is_same_v, "Buffer element type is boolean"); pIStream->read((char*)dest, numInstances * sizeof(T)); if (pIStream->bad()) - throw std::runtime_error( - "Failed to read little endian dynamic buffer of " + std::to_string(numInstances) + " instances"); + throw std::runtime_error("Failed to read typed (" + std::string(typeid(T).name()) + ") dynamic buffer of " + + std::to_string(numInstances) + " instances"); if constexpr (Misc::IS_BIG_ENDIAN) for (std::size_t i = 0; i < numInstances; i++) Misc::swapEndiannessInplace(dest[i]);