From f529ba94eceb3659ef329f1b0957f61292c5438f Mon Sep 17 00:00:00 2001 From: Ben Deane Date: Wed, 29 Apr 2026 15:08:11 -0600 Subject: [PATCH 1/4] :fire: Remove `CONSTINIT` macro Problem: - All targeted compilers support `constinit`. There is no need for `CONSTINIT` any more. Solution: - Remove `CONSTINIT` macro. --- docs/compiler.adoc | 1 - include/stdx/compiler.hpp | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/docs/compiler.adoc b/docs/compiler.adoc index 89aa9a81..610b5319 100644 --- a/docs/compiler.adoc +++ b/docs/compiler.adoc @@ -7,7 +7,6 @@ to compiler-specific attributes: * https://clang.llvm.org/docs/AttributeReference.html#always-inline-force-inline[`ALWAYS_INLINE`] * https://en.cppreference.com/w/cpp/language/consteval[`CONSTEVAL`] -* https://en.cppreference.com/w/cpp/language/constinit[`CONSTINIT`] * https://clang.llvm.org/docs/AttributeReference.html#lifetimebound[`LIFETIMEBOUND`] * https://clang.llvm.org/docs/AttributeReference.html#musttail[`MUSTTAIL`] * https://clang.llvm.org/docs/AttributeReference.html#noinline[`NEVER_INLINE`] diff --git a/include/stdx/compiler.hpp b/include/stdx/compiler.hpp index 5b1c2d0d..2f7afbfc 100644 --- a/include/stdx/compiler.hpp +++ b/include/stdx/compiler.hpp @@ -2,18 +2,6 @@ // NOLINTBEGIN(cppcoreguidelines-macro-usage) -#ifndef CONSTINIT -#ifndef __cpp_constinit -#ifdef __clang__ -#define CONSTINIT [[clang::require_constant_initialization]] -#else -#define CONSTINIT -#endif -#else -#define CONSTINIT constinit -#endif -#endif - #ifndef CONSTEVAL #ifndef __cpp_consteval #define CONSTEVAL constexpr From 2745869d99eb4983acdece40c589c6d7ab92edf7 Mon Sep 17 00:00:00 2001 From: Ben Deane Date: Wed, 29 Apr 2026 15:09:32 -0600 Subject: [PATCH 2/4] :bug: Fix `STDX_NRVO` macro definition Problem: - `STDX_NRVO` is detected incorrectly with `NRVO`. Solution: - Fix the detection. --- include/stdx/compiler.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/stdx/compiler.hpp b/include/stdx/compiler.hpp index 2f7afbfc..d2d7f258 100644 --- a/include/stdx/compiler.hpp +++ b/include/stdx/compiler.hpp @@ -77,7 +77,7 @@ #endif #endif -#ifndef NRVO +#ifndef STDX_NRVO #ifdef __clang__ #define STDX_NRVO(x) std::move(x) #else From 249c141490e6abadc483099c1533536f83ef2ff3 Mon Sep 17 00:00:00 2001 From: Ben Deane Date: Wed, 29 Apr 2026 15:13:59 -0600 Subject: [PATCH 3/4] :fire: Remove `CONSTEVAL` macro Problem: - All targeted compilers support `consteval`. There is no need for `CONSTEVAL` any more. Solution: - Remove `CONSTEVAL` macro. --- docs/compiler.adoc | 1 - include/stdx/bit.hpp | 4 ++-- include/stdx/bitset.hpp | 2 +- include/stdx/call_by_need.hpp | 8 ++++---- include/stdx/compiler.hpp | 10 +-------- include/stdx/ct_conversions.hpp | 6 +++--- include/stdx/ct_format.hpp | 36 ++++++++++++++++----------------- include/stdx/ct_string.hpp | 18 ++++++++--------- include/stdx/detail/fmt.hpp | 22 ++++++++++---------- include/stdx/env.hpp | 8 ++++---- include/stdx/iterator.hpp | 2 +- include/stdx/type_traits.hpp | 12 +++++------ include/stdx/udls.hpp | 6 +++--- include/stdx/utility.hpp | 10 ++++----- test/env.cpp | 6 +++--- 15 files changed, 71 insertions(+), 80 deletions(-) diff --git a/docs/compiler.adoc b/docs/compiler.adoc index 610b5319..940be336 100644 --- a/docs/compiler.adoc +++ b/docs/compiler.adoc @@ -6,7 +6,6 @@ provides macros for decorating declarations, which resolve either to keywords or to compiler-specific attributes: * https://clang.llvm.org/docs/AttributeReference.html#always-inline-force-inline[`ALWAYS_INLINE`] -* https://en.cppreference.com/w/cpp/language/consteval[`CONSTEVAL`] * https://clang.llvm.org/docs/AttributeReference.html#lifetimebound[`LIFETIMEBOUND`] * https://clang.llvm.org/docs/AttributeReference.html#musttail[`MUSTTAIL`] * https://clang.llvm.org/docs/AttributeReference.html#noinline[`NEVER_INLINE`] diff --git a/include/stdx/bit.hpp b/include/stdx/bit.hpp index 11427178..4cc930b7 100644 --- a/include/stdx/bit.hpp +++ b/include/stdx/bit.hpp @@ -403,7 +403,7 @@ template struct bitmask_subtract> { template - 1, std::size_t Lsb = 0> -[[nodiscard]] CONSTEVAL auto bit_mask() noexcept -> T { +[[nodiscard]] consteval auto bit_mask() noexcept -> T { static_assert(Msb < detail::num_digits_v, "bit_mask requested exceeds the range of the type"); static_assert(Msb >= Lsb, "bit_mask range is invalid"); @@ -422,7 +422,7 @@ template constexpr auto bit_size() -> std::size_t { return sizeof(T) * CHAR_BIT; } -template CONSTEVAL auto smallest_uint() { +template consteval auto smallest_uint() { if constexpr (N <= std::numeric_limits::digits) { return std::uint8_t{}; } else if constexpr (N <= std::numeric_limits::digits) { diff --git a/include/stdx/bitset.hpp b/include/stdx/bitset.hpp index 5f9c88f8..b897a8e1 100644 --- a/include/stdx/bitset.hpp +++ b/include/stdx/bitset.hpp @@ -102,7 +102,7 @@ class bitset { using iter_arg_t = conditional_t, decltype(Size), std::size_t>; - template CONSTEVAL static auto admissible_enum() { + template consteval static auto admissible_enum() { return not std::is_enum_v or std::is_same_v; } diff --git a/include/stdx/call_by_need.hpp b/include/stdx/call_by_need.hpp index 509b0662..daef889a 100644 --- a/include/stdx/call_by_need.hpp +++ b/include/stdx/call_by_need.hpp @@ -27,14 +27,14 @@ struct call_info { }; template -CONSTEVAL auto truncate_array(std::array const &arr) { +consteval auto truncate_array(std::array const &arr) { return [&](std::index_sequence) { return std::array{arr[Is]...}; }(std::make_index_sequence{}); } template -CONSTEVAL auto concat(std::array const &a1, std::array const &a2) +consteval auto concat(std::array const &a1, std::array const &a2) -> std::array { std::array result{}; auto it = std::copy(std::cbegin(a1), std::cend(a1), std::begin(result)); @@ -64,7 +64,7 @@ constexpr auto invoke(F &&f, Args &&args) -> decltype(auto) { template struct by_need { template - [[nodiscard]] CONSTEVAL static auto compute_call_info_impl() { + [[nodiscard]] consteval static auto compute_call_info_impl() { auto results = std::array{}; auto result_count = std::size_t{}; @@ -108,7 +108,7 @@ template struct by_need { } template - [[nodiscard]] CONSTEVAL static auto compute_call_info() { + [[nodiscard]] consteval static auto compute_call_info() { constexpr auto given_calls = [] { constexpr auto cs = compute_call_info_impl(); return truncate_array(cs.first); diff --git a/include/stdx/compiler.hpp b/include/stdx/compiler.hpp index d2d7f258..7d44dcaf 100644 --- a/include/stdx/compiler.hpp +++ b/include/stdx/compiler.hpp @@ -2,19 +2,11 @@ // NOLINTBEGIN(cppcoreguidelines-macro-usage) -#ifndef CONSTEVAL -#ifndef __cpp_consteval -#define CONSTEVAL constexpr -#else -#define CONSTEVAL consteval -#endif -#endif - #ifndef CONSTEVAL_UDL #ifdef __clang__ #define CONSTEVAL_UDL constexpr #else -#define CONSTEVAL_UDL CONSTEVAL +#define CONSTEVAL_UDL consteval #endif #endif diff --git a/include/stdx/ct_conversions.hpp b/include/stdx/ct_conversions.hpp index 64ca5867..0cd9005e 100644 --- a/include/stdx/ct_conversions.hpp +++ b/include/stdx/ct_conversions.hpp @@ -9,7 +9,7 @@ inline namespace v1 { template constexpr bool always_false_v = false; template -CONSTEVAL static auto type_as_string() -> std::string_view { +consteval static auto type_as_string() -> std::string_view { #ifdef __clang__ constexpr std::string_view function_name = __PRETTY_FUNCTION__; constexpr auto rhs = function_name.size() - 2; @@ -26,14 +26,14 @@ CONSTEVAL static auto type_as_string() -> std::string_view { } template -CONSTEVAL static auto template_base() -> std::string_view { +consteval static auto template_base() -> std::string_view { constexpr auto t = stdx::type_as_string(); constexpr auto rhs = t.find('<'); return t.substr(0, rhs); } template -CONSTEVAL static auto enum_as_string() -> std::basic_string_view { +consteval static auto enum_as_string() -> std::basic_string_view { #ifdef __clang__ constexpr std::string_view value_string = __PRETTY_FUNCTION__; #elif defined(__GNUC__) || defined(__GNUG__) diff --git a/include/stdx/ct_format.hpp b/include/stdx/ct_format.hpp index dc99c44b..12fdc834 100644 --- a/include/stdx/ct_format.hpp +++ b/include/stdx/ct_format.hpp @@ -36,7 +36,7 @@ struct named_arg { constexpr static std::integral_constant is_runtime{}; template - CONSTEVAL static auto apply_offset() { + consteval static auto apply_offset() { if constexpr (is_runtime) { return named_arg{}; } else { @@ -65,7 +65,7 @@ using apply_offset = template struct format_result { - CONSTEVAL static auto ct_string_convertible() + consteval static auto ct_string_convertible() -> std::bool_constant; [[no_unique_address]] Str str; @@ -92,7 +92,7 @@ struct format_result { template requires(Args::size() == 0 and is_cx_value_v) struct format_result { - CONSTEVAL static auto ct_string_convertible() -> std::true_type; + consteval static auto ct_string_convertible() -> std::true_type; [[no_unique_address]] Str str; [[no_unique_address]] Args args{}; @@ -123,7 +123,7 @@ template CONSTEVAL_UDL auto operator""_fmt_res() { } // namespace literals namespace detail { -template CONSTEVAL auto find_spec(It first, It last) -> It { +template consteval auto find_spec(It first, It last) -> It { for (auto spec_start = std::find(first, last, '{'); spec_start != last; spec_start = std::find(spec_start, last, '{')) { if (spec_start + 1 != last) { @@ -137,7 +137,7 @@ template CONSTEVAL auto find_spec(It first, It last) -> It { return last; } -CONSTEVAL auto count_specifiers(std::string_view fmt) -> std::size_t { +consteval auto count_specifiers(std::string_view fmt) -> std::size_t { auto count = std::size_t{}; for (auto spec_start = find_spec(fmt.begin(), fmt.end()); spec_start != fmt.end(); @@ -157,7 +157,7 @@ struct split_spec { }; template -CONSTEVAL auto split_specifiers(std::string_view fmt) +consteval auto split_specifiers(std::string_view fmt) -> std::array { auto splits = std::array{}; auto count = std::size_t{}; @@ -182,7 +182,7 @@ CONSTEVAL auto split_specifiers(std::string_view fmt) return splits; } -template CONSTEVAL auto extract_format1_str() { +template consteval auto extract_format1_str() { constexpr auto name_start = Start + 1; constexpr auto it = [] { for (auto i = S.value.cbegin() + name_start; i != S.value.cend(); ++i) { @@ -231,7 +231,7 @@ concept fmt_cx_value = is_cx_value_v or requires(T t) { ct_string_from_type(t); }; template -CONSTEVAL auto arg_value(std::integral_constant) { +consteval auto arg_value(std::integral_constant) { if constexpr (std::is_enum_v) { return enum_as_string(); } else { @@ -239,13 +239,13 @@ CONSTEVAL auto arg_value(std::integral_constant) { } } -template CONSTEVAL auto arg_value(type_identity) { +template consteval auto arg_value(type_identity) { return type_as_string(); } -template CONSTEVAL auto arg_value(cts_t) { return S; } +template consteval auto arg_value(cts_t) { return S; } -CONSTEVAL auto arg_value(fmt_cx_value auto a) { +consteval auto arg_value(fmt_cx_value auto a) { if constexpr (is_specialization_of_v) { return a; } else if constexpr (requires { arg_value(a()); }) { @@ -259,12 +259,12 @@ CONSTEVAL auto arg_value(fmt_cx_value auto a) { } } -template CONSTEVAL auto arg_type(T) -> T; +template consteval auto arg_type(T) -> T; template -CONSTEVAL auto arg_type(std::integral_constant) -> T; +consteval auto arg_type(std::integral_constant) -> T; -CONSTEVAL auto arg_type(fmt_cx_value auto a) { +consteval auto arg_type(fmt_cx_value auto a) { if constexpr (requires { ct_string_from_type(a); }) { return ct_string_from_type(a); } else { @@ -301,11 +301,11 @@ constexpr auto operator+(format_result r1, template struct null_output; -template CONSTEVAL auto to_ct_string(std::string_view s) { +template consteval auto to_ct_string(std::string_view s) { return ct_string{s.data(), s.size()}; } -CONSTEVAL auto convert_input(auto s) { +consteval auto convert_input(auto s) { if constexpr (requires { ct_string_from_type(s); }) { return ct_string_from_type(s); } else { @@ -315,7 +315,7 @@ CONSTEVAL auto convert_input(auto s) { template typename Output = detail::null_output> -CONSTEVAL auto convert_output() { +consteval auto convert_output() { if constexpr (same_as, null_output>) { return cts_t{}; } else { @@ -324,7 +324,7 @@ CONSTEVAL auto convert_output() { } template -CONSTEVAL auto perform_format(auto s, auto const &v) -> ct_string { +consteval auto perform_format(auto s, auto const &v) -> ct_string { ct_string cts{}; fmt::format_to(cts.begin(), s, v); return cts; diff --git a/include/stdx/ct_string.hpp b/include/stdx/ct_string.hpp index 00100286..1b68ddaa 100644 --- a/include/stdx/ct_string.hpp +++ b/include/stdx/ct_string.hpp @@ -25,10 +25,10 @@ concept format_convertible = requires(T t) { } // namespace detail template struct ct_string { - CONSTEVAL ct_string() = default; + consteval ct_string() = default; // NOLINTNEXTLINE(*-avoid-c-arrays, google-explicit-constructor) - CONSTEVAL explicit(false) ct_string(char const (&str)[N]) { + consteval explicit(false) ct_string(char const (&str)[N]) { for (auto i = std::size_t{}; i < N; ++i) { // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-*) value[i] = str[i]; @@ -37,16 +37,16 @@ template struct ct_string { template // NOLINTNEXTLINE(google-explicit-constructor) - CONSTEVAL explicit(false) ct_string(T t) : ct_string(+t) {} + consteval explicit(false) ct_string(T t) : ct_string(+t) {} - CONSTEVAL explicit(true) ct_string(char const *str, std::size_t sz) { + consteval explicit(true) ct_string(char const *str, std::size_t sz) { for (auto i = std::size_t{}; i < sz; ++i) { // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-*) value[i] = str[i]; } } - CONSTEVAL explicit(true) ct_string(std::string_view str) + consteval explicit(true) ct_string(std::string_view str) : ct_string{str.data(), str.size()} {} [[nodiscard]] constexpr auto begin() LIFETIMEBOUND { return value.begin(); } @@ -86,12 +86,12 @@ template } template