From 4b8e1a2fb660f914e81cb90b975c470a8f36adf7 Mon Sep 17 00:00:00 2001 From: Ben Deane Date: Wed, 22 May 2024 11:52:27 -0600 Subject: [PATCH] :bug: Remove erroneous constraint on operator+ for ct_format --- include/stdx/ct_format.hpp | 1 - test/ct_format.cpp | 11 +++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/stdx/ct_format.hpp b/include/stdx/ct_format.hpp index b32c175..b954d72 100644 --- a/include/stdx/ct_format.hpp +++ b/include/stdx/ct_format.hpp @@ -112,7 +112,6 @@ CONSTEVAL auto operator+(format_result r, S s) { } template - requires(is_specialization_of().value) CONSTEVAL auto operator+(S s, format_result r) { return format_result{s + r.str, r.args}; } diff --git a/test/ct_format.cpp b/test/ct_format.cpp index a5cdd04..31111b8 100644 --- a/test/ct_format.cpp +++ b/test/ct_format.cpp @@ -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{}); } + +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)}); +}