diff --git a/include/boost/static_string/config.hpp b/include/boost/static_string/config.hpp index c46ed57..7789e34 100644 --- a/include/boost/static_string/config.hpp +++ b/include/boost/static_string/config.hpp @@ -21,7 +21,7 @@ // #define BOOST_STATIC_STRING_NULL_OPTIMIZATION // Can we have deduction guides? -#ifdef __cpp_deduction_guides +#if __cpp_deduction_guides >= 201703 #define BOOST_STATIC_STRING_USE_DEDUCT #endif @@ -36,7 +36,14 @@ #define BOOST_STATIC_STRING_NODISCARD #endif -#if __cplusplus > 201703L +// MSVC doesn't define __cplusplus by default +#ifdef _MSVC_LANG +#define BOOST_STATIC_STRING_STANDARD_VERSION _MSVC_LANG +#else +#define BOOST_STATIC_STRING_STANDARD_VERSION __cplusplus +#endif + +#if BOOST_STATIC_STRING_STANDARD_VERSION > 201703L #define BOOST_STATIC_STRING_CPP20_CONSTEXPR constexpr #define BOOST_STATIC_STRING_CPP17_CONSTEXPR constexpr #define BOOST_STATIC_STRING_CPP14_CONSTEXPR constexpr @@ -46,7 +53,7 @@ #define BOOST_STATIC_STRING_CPP14_CONSTEXPR_USED #define BOOST_STATIC_STRING_CPP11_CONSTEXPR_USED #define BOOST_STATIC_STRING_ALLOW_UNINIT_MEM -#elif __cplusplus >= 201703L +#elif BOOST_STATIC_STRING_STANDARD_VERSION >= 201703L #define BOOST_STATIC_STRING_CPP20_CONSTEXPR #define BOOST_STATIC_STRING_CPP17_CONSTEXPR constexpr #define BOOST_STATIC_STRING_CPP14_CONSTEXPR constexpr @@ -54,7 +61,7 @@ #define BOOST_STATIC_STRING_CPP17_CONSTEXPR_USED #define BOOST_STATIC_STRING_CPP14_CONSTEXPR_USED #define BOOST_STATIC_STRING_CPP11_CONSTEXPR_USED -#elif __cplusplus >= 201402L +#elif BOOST_STATIC_STRING_STANDARD_VERSION >= 201402L #define BOOST_STATIC_STRING_CPP20_CONSTEXPR #define BOOST_STATIC_STRING_CPP17_CONSTEXPR #define BOOST_STATIC_STRING_CPP14_CONSTEXPR constexpr @@ -117,8 +124,8 @@ #endif #endif -#if (__cplusplus >= 201402L) && \ -(__cplusplus < 201703L) && \ +#if (BOOST_STATIC_STRING_STANDARD_VERSION >= 201402L) && \ +(BOOST_STATIC_STRING_STANDARD_VERSION < 201703L) && \ defined(__clang__) && \ ((__clang_major__ == 4) || (__clang_major__ == 5)) // This directive works on clang diff --git a/include/boost/static_string/detail/static_string.hpp b/include/boost/static_string/detail/static_string.hpp index 8d335ce..f466f02 100644 --- a/include/boost/static_string/detail/static_string.hpp +++ b/include/boost/static_string/detail/static_string.hpp @@ -63,9 +63,16 @@ struct is_nothrow_convertible::value>::type> : std::true_type { }; -// void_t for c++11 +// GCC 4.8, 4.9 workaround for void_t to make the defining-type-id dependant template -using void_t = void; +struct void_t_helper +{ + using type = void; +}; + +// void_t for c++11 +template +using void_t = typename void_t_helper::type; // Simplified check for if a type is an iterator template diff --git a/include/boost/static_string/impl/static_string.hpp b/include/boost/static_string/impl/static_string.hpp index 5438bbb..be2b977 100644 --- a/include/boost/static_string/impl/static_string.hpp +++ b/include/boost/static_string/impl/static_string.hpp @@ -337,8 +337,8 @@ insert( count > max_size() - curr_size, std::length_error{"count() > max_size() - size()"}); auto const index = pos - curr_data; Traits::move(&curr_data[index + count], &curr_data[index], curr_size - index); - this->set_size(curr_size + count); Traits::assign(&curr_data[index], count, ch); + this->set_size(curr_size + count); term(); return &curr_data[index]; }