Skip to content

Commit

Permalink
Merge pull request #103 from elbeno/fix-ct-format-bug
Browse files Browse the repository at this point in the history
🐛 Remove erroneous constraint on operator+ for ct_format
  • Loading branch information
bdeane-intel authored May 22, 2024
2 parents 9cf702d + 4b8e1a2 commit 0bd6078
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 0 additions & 1 deletion include/stdx/ct_format.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ CONSTEVAL auto operator+(format_result<T, U> r, S s) {
}

template <typename S, typename T, typename U>
requires(is_specialization_of<S, ct_string>().value)
CONSTEVAL auto operator+(S s, format_result<T, U> r) {
return format_result{s + r.str, r.args};
}
Expand Down
11 changes: 11 additions & 0 deletions test/ct_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,14 @@ TEST_CASE("format a ct-formatted string with different type", "[ct_format]") {
stdx::ct_format<"A{}D", string_constant>(CX_VALUE(cts)) ==
string_constant<char, 'A', 'B', '2', '0', '2', '4', 'C', 'D'>{});
}

TEST_CASE("format multiple mixed arguments with different type",
"[ct_format]") {
using namespace std::string_view_literals;
static_assert(stdx::ct_format<"Hello {} {} {} {} world", string_constant>(
42, CX_VALUE("A"sv), "B"sv, CX_VALUE(int)) ==
stdx::format_result{
stdx::ct_string_to_type<"Hello {} A {} int world"_cts,
string_constant>(),
stdx::make_tuple(42, "B"sv)});
}

0 comments on commit 0bd6078

Please sign in to comment.