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: 4 additions & 0 deletions include/stdx/ct_format.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ constexpr auto ct_format = [](auto &&...args) {

using data = detail::fmt_data<Fmt>;

static_assert(data::N == sizeof...(args),
"Format string has a mismatch between the number of format "
"specifiers and arguments.");

[[maybe_unused]] auto const format1 = [&]<std::size_t I>(auto &&arg) {
constexpr auto cts =
detail::to_ct_string<data::splits[I].size()>(data::splits[I]);
Expand Down
1 change: 1 addition & 0 deletions test/fail/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ if(${CMAKE_CXX_STANDARD} GREATER_EQUAL 20)

add_fail_tests(
atomic_bool_dec
ct_format_mismatch
dynamic_span_no_ct_capacity
dynamic_container_no_ct_capacity
tuple_index_out_of_bounds
Expand Down
5 changes: 5 additions & 0 deletions test/fail/ct_format_mismatch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <stdx/ct_format.hpp>

// EXPECT: mismatch between the number of format specifiers and arguments

auto main() -> int { [[maybe_unused]] auto x = stdx::ct_format<"Hello">(42); }