Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/boost/static_string/static_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,7 @@ class basic_static_string
BOOST_STATIC_STRING_CPP14_CONSTEXPR
basic_static_string(const_pointer s)
{
assign(s);
assign(s, s + traits_type::length(s));
}

/** Constructor.
Expand Down Expand Up @@ -1373,7 +1373,7 @@ class basic_static_string
basic_static_string&
operator=(const_pointer s)
{
return assign(s);
return assign(s, s + traits_type::length(s));
}

/** Assign to the string.
Expand Down
16 changes: 16 additions & 0 deletions test/constexpr_tests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,22 @@ bool
testConstantEvaluation()
{
#ifdef BOOST_STATIC_STRING_CPP20

// Check construction in a constexpr context
constexpr basic_static_string s("hello");
static_assert(s.size() == 5);
static_assert(s == "hello");

// Check assignment in a constexpr context
constexpr auto s2 =
[]()
{
basic_static_string s("hello");
s = "world";
return s;
}();
static_assert(s2 == "world");

// c++20 constexpr tests
cstatic_string a;
cstatic_string b(1, 'a');
Expand Down