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
8 changes: 6 additions & 2 deletions include/stdx/ct_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,18 @@ template <ct_string S> CONSTEVAL auto operator""_cts() { return S; }
} // namespace ct_string_literals
} // namespace literals

struct ct_check_value {};

template <bool B> struct ct_check_t {
template <ct_string S> constexpr static bool diagnostic = false;
template <ct_string S>
constexpr static auto emit() -> void
constexpr static auto emit() -> ct_check_value
requires diagnostic<S>;
};
template <> struct ct_check_t<true> {
template <ct_string S> constexpr static auto emit() -> void {}
template <ct_string S> constexpr static auto emit() -> ct_check_value {
return {};
}
};
template <bool B> constexpr auto ct_check = ct_check_t<B>{};

Expand Down
2 changes: 1 addition & 1 deletion test/fail/ct_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ constexpr auto msg =
stdx::ct_string{"01234567890123456789012345678901234567890123456789"};

auto main() -> int {
stdx::ct_check<true>.emit<"not emitted">();
[[maybe_unused]] auto x = stdx::ct_check<true>.emit<"not emitted">();
stdx::ct_check<false>.emit<msg>();
}