diff --git a/.travis.yml b/.travis.yml index 4f675c1..29e65ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -190,15 +190,18 @@ jobs: - { os: "linux", env: [ "B2_TOOLSET=clang-6.0", "B2_CXXSTD=14,17" ], addons: *clang-6 } - { os: "linux", env: [ "B2_TOOLSET=clang-7", "B2_CXXSTD=17" ], addons: *clang-7 } - os: "linux" - env: ["B2_TOOLSET=clang-9", "B2_CXXSTD=17", "B2_CXXFLAGS=-stdlib=libstdc++"] - apt: - sources: - - ubuntu-toolchain-r-test - - sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main' - key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key' - packages: - - clang-9 - + env: ["B2_TOOLSET=clang-9", "B2_CXXSTD=11,14,17"] + addons: + apt: + sources: + - ubuntu-toolchain-r-test + - sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main' + key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key' + packages: + - clang-9 + - libc6-dbg + - libc++-dev + - libstdc++-8-dev - { os: "linux", env: [ "B2_TOOLSET=clang-8", "B2_CXXSTD=17" ], addons: *clang-8 } # libc++ diff --git a/include/boost/static_string/static_string.hpp b/include/boost/static_string/static_string.hpp index ef4b7e9..b4d0f31 100644 --- a/include/boost/static_string/static_string.hpp +++ b/include/boost/static_string/static_string.hpp @@ -257,11 +257,11 @@ public: term_impl() noexcept { } private: - static constexpr CharT null_{}; + static constexpr const CharT null_{}; }; template -constexpr CharT static_string_base_zero<0, CharT, Traits>::null_; +constexpr const CharT static_string_base_zero<0, CharT, Traits>::null_; #ifdef BOOST_STATIC_STRING_NULL_OPTIMIZATION // Optimization for storing the size in the last element @@ -502,10 +502,22 @@ to_static_wstring_int_impl(Integer value) noexcept return static_wstring(digits_begin, std::distance(digits_begin, digits_end)); } -template +template inline static_string -to_static_string_float_impl(Floating value) noexcept +to_static_string_float_impl(double value) noexcept +{ + // extra one needed for null terminator + char buffer[N + 1]; + std::sprintf(buffer, "%f", value); + // this will not throw + return static_string(buffer); +} + +template +inline +static_string +to_static_string_float_impl(long double value) noexcept { // extra one needed for null terminator char buffer[N + 1]; @@ -514,10 +526,22 @@ to_static_string_float_impl(Floating value) noexcept return static_string(buffer); } -template +template inline static_wstring -to_static_wstring_float_impl(Floating value) noexcept +to_static_wstring_float_impl(double value) noexcept +{ + // extra one needed for null terminator + wchar_t buffer[N + 1]; + std::swprintf(buffer, N + 1, L"%f", value); + // this will not throw + return static_wstring(buffer); +} + +template +inline +static_wstring +to_static_wstring_float_impl(long double value) noexcept { // extra one needed for null terminator wchar_t buffer[N + 1];