Skip to content

Commit 5f65449

Browse files
authored
Merge pull request #245 from elbeno/ctst-cts-concat
2 parents 543e357 + 3e6b388 commit 5f65449

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

include/stdx/ct_string.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,16 @@ constexpr auto operator+(cts_t<X>, cts_t<Y>) {
157157
return cts_t<X + Y>{};
158158
}
159159

160+
template <std::size_t N, ct_string S>
161+
[[nodiscard]] constexpr auto operator+(ct_string<N> const &lhs, cts_t<S> rhs) {
162+
return lhs + +rhs;
163+
}
164+
165+
template <ct_string S, std::size_t N>
166+
[[nodiscard]] constexpr auto operator+(cts_t<S> lhs, ct_string<N> const &rhs) {
167+
return +lhs + rhs;
168+
}
169+
160170
namespace detail {
161171
template <std::size_t N> struct ct_helper<ct_string<N>>;
162172
} // namespace detail

test/ct_string.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,9 @@ TEST_CASE("cts_t can implicitly convert to ct_string", "[ct_string]") {
159159
using namespace stdx::ct_string_literals;
160160
STATIC_REQUIRE(conversion_success<"Hello"_ctst>);
161161
}
162+
163+
TEST_CASE("operator+ works to concat cts_t and ct_string", "[ct_string]") {
164+
using namespace stdx::ct_string_literals;
165+
STATIC_REQUIRE("Hello"_ctst + " world"_cts == "Hello world"_cts);
166+
STATIC_REQUIRE("Hello"_cts + " world"_ctst == "Hello world"_cts);
167+
}

0 commit comments

Comments
 (0)