Skip to content

Commit

Permalink
introduce FixedString::operator+(FixedString)
Browse files Browse the repository at this point in the history
  • Loading branch information
Younes Reda committed Jul 5, 2024
1 parent 73fb715 commit 5f5045f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/fixed_containers/fixed_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,14 @@ template <std::size_t MAXIMUM_LENGTH_WITH_NULL_TERMINATOR>
list, loc);
}

template <std::size_t N, std::size_t M>
constexpr FixedString<N + M> operator+(const FixedString<N>& a, const FixedString<M>& b)
{
FixedString<N + M> result(a);
result.append(b);
return result;
}

} // namespace fixed_containers

// Specializations
Expand Down
5 changes: 5 additions & 0 deletions test/fixed_string_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,11 @@ TEST(FixedStringTest, OStreamOperator)
EXPECT_EQ(ss.str(), "hello");
}

TEST(FixedStringTest, PlusOperator)
{
static_assert(make_fixed_string("hello world") == (make_fixed_string("hello ") + make_fixed_string("world")));
}

namespace
{
template <FixedString<5> /*MY_STR*/>
Expand Down

0 comments on commit 5f5045f

Please sign in to comment.