From 38185d594215f85c5967a0ac68dd3c7206c4c277 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski Date: Fri, 21 Feb 2020 15:37:22 -0500 Subject: [PATCH] Fix weird clang link error --- include/boost/static_string/static_string.hpp | 39 +++++++------ test/static_string.cpp | 56 +++++++++---------- 2 files changed, 51 insertions(+), 44 deletions(-) diff --git a/include/boost/static_string/static_string.hpp b/include/boost/static_string/static_string.hpp index e425500..3b945e9 100644 --- a/include/boost/static_string/static_string.hpp +++ b/include/boost/static_string/static_string.hpp @@ -927,7 +927,14 @@ public: */ BOOST_STATIC_STRING_CPP14_CONSTEXPR basic_static_string& - assign(const basic_static_string& s) noexcept; + assign(const basic_static_string& s) noexcept + { + if (this == &s) + return *this; + this->set_size(s.size()); + traits_type::copy(data(), &s.data()[0], size() + 1); + return *this; + } /** Replace the contents. @@ -942,8 +949,8 @@ public: assign(const basic_static_string& s) { // VFALCO this could come in two flavors, - // N>M and NM + // N > M and N < M, and skip the exception + // check when N > M return assign(s.data(), s.size()); } @@ -4781,19 +4788,19 @@ assign( return term(); } -template -BOOST_STATIC_STRING_CPP14_CONSTEXPR -auto -basic_static_string:: -assign(const basic_static_string& s) noexcept -> - basic_static_string& -{ - if(this == &s) - return *this; - this->set_size(s.size()); - traits_type::copy(data(), &s.data()[0], size() + 1); - return *this; -} +//template +//BOOST_STATIC_STRING_CPP14_CONSTEXPR +//auto +//basic_static_string:: +//assign(const basic_static_string& s) noexcept -> +// basic_static_string& +//{ +// if(this == &s) +// return *this; +// this->set_size(s.size()); +// traits_type::copy(data(), &s.data()[0], size() + 1); +// return *this; +//} template template diff --git a/test/static_string.cpp b/test/static_string.cpp index 47591d3..b400cc9 100644 --- a/test/static_string.cpp +++ b/test/static_string.cpp @@ -7042,37 +7042,37 @@ testOperatorPlus() BOOST_TEST(res.size() == 10); } - //// operator+(static_string, CharT) - //{ - // auto res = s1 + '!'; - // BOOST_TEST(res == "hello!"); - // BOOST_TEST(res.capacity() == 11); - // BOOST_TEST(res.size() == 6); - //} + // operator+(static_string, CharT) + { + auto res = s1 + '!'; + BOOST_TEST(res == "hello!"); + BOOST_TEST(res.capacity() == 11); + BOOST_TEST(res.size() == 6); + } - //// operator+(CharT, static_string) - //{ - // auto res = '!' + s1; - // BOOST_TEST(res == "!hello"); - // BOOST_TEST(res.capacity() == 11); - // BOOST_TEST(res.size() == 6); - //} + // operator+(CharT, static_string) + { + auto res = '!' + s1; + BOOST_TEST(res == "!hello"); + BOOST_TEST(res.capacity() == 11); + BOOST_TEST(res.size() == 6); + } - //// operator+(static_string, CharT(&)[N]) - //{ - // auto res = s1 + "world"; - // BOOST_TEST(res == "helloworld"); - // BOOST_TEST(res.capacity() == 15); - // BOOST_TEST(res.size() == 10); - //} + // operator+(static_string, CharT(&)[N]) + { + auto res = s1 + "world"; + BOOST_TEST(res == "helloworld"); + BOOST_TEST(res.capacity() == 15); + BOOST_TEST(res.size() == 10); + } - //// operator+(CharT(&)[N], static_string) - //{ - // auto res = "hello" + s2; - // BOOST_TEST(res == "helloworld"); - // BOOST_TEST(res.capacity() == 15); - // BOOST_TEST(res.size() == 10); - //} + // operator+(CharT(&)[N], static_string) + { + auto res = "hello" + s2; + BOOST_TEST(res == "helloworld"); + BOOST_TEST(res.capacity() == 15); + BOOST_TEST(res.size() == 10); + } } int