diff --git a/include/boost/static_string/config.hpp b/include/boost/static_string/config.hpp index fbec78a..1a1a49b 100644 --- a/include/boost/static_string/config.hpp +++ b/include/boost/static_string/config.hpp @@ -17,6 +17,9 @@ // Disable exceptions and their associated checks // #define BOOST_STATIC_STRING_NO_EXCEPTIONS +// Opt-in to the null terminator optimization +// #define BOOST_STATIC_STRING_NULL_OPTIMIZATION + // Can we have deduction guides? #ifdef __cpp_deduction_guides #define BOOST_STATIC_STRING_USE_DEDUCT @@ -33,9 +36,6 @@ #define BOOST_STATIC_STRING_NODISCARD #endif -//#undef _­_­cplusplus -//#define _­_­cplusplus 201703L - #if __cplusplus > 201703L #define BOOST_STATIC_STRING_CPP20_CONSTEXPR constexpr #define BOOST_STATIC_STRING_CPP17_CONSTEXPR constexpr @@ -114,6 +114,10 @@ #endif #endif +#if (__cplusplus >= 201402L) && (__cplusplus < 201703L) && defined(BOOST_STATIC_STRING_NULL_OPTIMIZATION) && defined(__clang__) && ((__clang_major__ == 4) || (__clang_major__ == 5)) +#error The null terminator optimization is not supported for clang 4.x and clang 5.x +#endif + namespace boost { namespace static_string { diff --git a/include/boost/static_string/detail/static_string.hpp b/include/boost/static_string/detail/static_string.hpp index 5032c40..d7fcf79 100644 --- a/include/boost/static_string/detail/static_string.hpp +++ b/include/boost/static_string/detail/static_string.hpp @@ -209,15 +209,13 @@ public: #endif }; -//#define BOOST_STATIC_STRING_NO_NULL_OPTIMIZATION - // Decides which size optimization to use // If the size is zero, the object will have no members // Otherwise, if CharT can hold the max size of the string, store the size in the last char // Otherwise, store the size of the string using a member of the smallest type possible template using optimization_base = -#ifndef BOOST_STATIC_STRING_NO_NULL_OPTIMIZATION +#ifdef BOOST_STATIC_STRING_USE_NULL_OPTIMIZATION typename std::conditional<(N <= (std::numeric_limits::max)()) && (N != 0), static_string_base_null, static_string_base_zero>::type;