From 7c8ad32ff97348c5ea93df308cc32c3262357747 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski Date: Mon, 16 Dec 2019 19:22:41 -0500 Subject: [PATCH] A object pointer value is only a constant expression if it points to an object with static storage duration. --- .../static_string/detail/static_string.hpp | 8 +++---- test/static_string.cpp | 21 +++++++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/include/boost/static_string/detail/static_string.hpp b/include/boost/static_string/detail/static_string.hpp index ec46d6d..5032c40 100644 --- a/include/boost/static_string/detail/static_string.hpp +++ b/include/boost/static_string/detail/static_string.hpp @@ -76,14 +76,14 @@ public: CharT* data_impl() noexcept { - return +data_; + return data_; } BOOST_STATIC_STRING_CPP14_CONSTEXPR CharT const* data_impl() const noexcept { - return +data_; + return data_; } BOOST_STATIC_STRING_CPP11_CONSTEXPR @@ -171,14 +171,14 @@ public: CharT* data_impl() noexcept { - return +data_; + return data_; } BOOST_STATIC_STRING_CPP14_CONSTEXPR CharT const* data_impl() const noexcept { - return +data_; + return data_; } BOOST_STATIC_STRING_CPP11_CONSTEXPR diff --git a/test/static_string.cpp b/test/static_string.cpp index 64ab6bd..180be03 100644 --- a/test/static_string.cpp +++ b/test/static_string.cpp @@ -6932,6 +6932,23 @@ constexpr bool testConstexpr() #elif __cplusplus >= 201703L // c++17 constexpr tests + using S = basic_static_string<16, char, cxper_char_traits>; + // ctor + { + constexpr S s1; + constexpr S s2(1, 'a'); + constexpr S s3(""); + constexpr S s4("", 1); + constexpr S s5 = s1; + constexpr auto b = s1.size(); + constexpr auto c = s1.empty(); + constexpr auto d = s1.max_size(); + constexpr auto e = s1.capacity(); + constexpr auto f = s1.length(); + constexpr auto g = s2.front(); + constexpr auto h = s2.back(); + } + #elif __cplusplus >= 201402L // c++14 constexpr tests @@ -6951,10 +6968,6 @@ constexpr bool testConstexpr() constexpr auto f = s1.length(); constexpr auto g = s2.front(); constexpr auto h = s2.back(); - constexpr auto k = s2.begin(); - constexpr auto l = s2.end(); - constexpr auto i = s2.data(); - constexpr auto j = s2.c_str(); } //constexpr auto g = s1.assign(1, '1');