From 135e4ef81940c6948c591e20960b3a64d9ed41b4 Mon Sep 17 00:00:00 2001 From: Hewill Kang Date: Tue, 23 Sep 2025 23:09:44 +0800 Subject: [PATCH 1/3] [const.wrap.class] Add missing namespace std --- source/meta.tex | 386 ++++++++++++++++++++++++------------------------ 1 file changed, 194 insertions(+), 192 deletions(-) diff --git a/source/meta.tex b/source/meta.tex index e848e048f8..bae5f0c25a 100644 --- a/source/meta.tex +++ b/source/meta.tex @@ -651,201 +651,203 @@ \rSec2[const.wrap.class]{Class template \tcode{constant_wrapper}} \begin{codeblock} -template -struct @\exposidnc{cw-fixed-value}@ { // \expos - using @\exposidnc{type}@ = T; // \expos - constexpr @\exposidnc{cw-fixed-value}@(@\exposidnc{type}@ v) noexcept : @\exposidnc{data}@(v) {} - T @\exposidnc{data}@; // \expos -}; - -template -struct @\exposidnc{cw-fixed-value}@ { // \expos - using @\exposidnc{type}@ = T[Extent]; // \expos - constexpr @\exposidnc{cw-fixed-value}@(T (&arr)[Extent]) noexcept; - T @\exposidnc{data}@[Extent]; // \expos -}; - -template - @\exposidnc{cw-fixed-value}@(T (&)[Extent]) -> @\exposidnc{cw-fixed-value}@; // \expos - -struct @\exposidnc{cw-operators}@ { // \expos - // unary operators - template<@\exposconcept{constexpr-param}@ T> - friend constexpr auto operator+(T) noexcept -> constant_wrapper<(+T::value)> - { return {}; } - template<@\exposconcept{constexpr-param}@ T> - friend constexpr auto operator-(T) noexcept -> constant_wrapper<(-T::value)> - { return {}; } - template<@\exposconcept{constexpr-param}@ T> - friend constexpr auto operator~(T) noexcept -> constant_wrapper<(~T::value)> - { return {}; } - template<@\exposconcept{constexpr-param}@ T> - friend constexpr auto operator!(T) noexcept -> constant_wrapper<(!T::value)> - { return {}; } - template<@\exposconcept{constexpr-param}@ T> - friend constexpr auto operator&(T) noexcept -> constant_wrapper<(&T::value)> - { return {}; } - template<@\exposconcept{constexpr-param}@ T> - friend constexpr auto operator*(T) noexcept -> constant_wrapper<(*T::value)> - { return {}; } - - // binary operators - template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> - friend constexpr auto operator+(L, R) noexcept -> constant_wrapper<(L::value + R::value)> - { return {}; } - template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> - friend constexpr auto operator-(L, R) noexcept -> constant_wrapper<(L::value - R::value)> - { return {}; } - template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> - friend constexpr auto operator*(L, R) noexcept -> constant_wrapper<(L::value * R::value)> - { return {}; } - template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> - friend constexpr auto operator/(L, R) noexcept -> constant_wrapper<(L::value / R::value)> - { return {}; } - template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> - friend constexpr auto operator%(L, R) noexcept -> constant_wrapper<(L::value % R::value)> - { return {}; } - - template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> - friend constexpr auto operator<<(L, R) noexcept -> constant_wrapper<(L::value << R::value)> - { return {}; } - template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> - friend constexpr auto operator>>(L, R) noexcept -> constant_wrapper<(L::value >> R::value)> - { return {}; } - template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> - friend constexpr auto operator&(L, R) noexcept -> constant_wrapper<(L::value & R::value)> - { return {}; } - template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> - friend constexpr auto operator|(L, R) noexcept -> constant_wrapper<(L::value | R::value)> - { return {}; } - template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> - friend constexpr auto operator^(L, R) noexcept -> constant_wrapper<(L::value ^ R::value)> - { return {}; } - - template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> - requires (!is_constructible_v || - !is_constructible_v) - friend constexpr auto operator&&(L, R) noexcept -> constant_wrapper<(L::value && R::value)> +namespace std { + template + struct @\exposidnc{cw-fixed-value}@ { // \expos + using @\exposidnc{type}@ = T; // \expos + constexpr @\exposidnc{cw-fixed-value}@(@\exposidnc{type}@ v) noexcept : @\exposidnc{data}@(v) {} + T @\exposidnc{data}@; // \expos + }; + + template + struct @\exposidnc{cw-fixed-value}@ { // \expos + using @\exposidnc{type}@ = T[Extent]; // \expos + constexpr @\exposidnc{cw-fixed-value}@(T (&arr)[Extent]) noexcept; + T @\exposidnc{data}@[Extent]; // \expos + }; + + template + @\exposidnc{cw-fixed-value}@(T (&)[Extent]) -> @\exposidnc{cw-fixed-value}@; // \expos + + struct @\exposidnc{cw-operators}@ { // \expos + // unary operators + template<@\exposconcept{constexpr-param}@ T> + friend constexpr auto operator+(T) noexcept -> constant_wrapper<(+T::value)> { return {}; } - template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> - requires (!is_constructible_v || - !is_constructible_v) - friend constexpr auto operator||(L, R) noexcept -> constant_wrapper<(L::value || R::value)> + template<@\exposconcept{constexpr-param}@ T> + friend constexpr auto operator-(T) noexcept -> constant_wrapper<(-T::value)> { return {}; } - - // comparisons - template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> - friend constexpr auto operator<=>(L, R) noexcept -> constant_wrapper<(L::value <=> R::value)> - { return {}; } - template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> - friend constexpr auto operator<(L, R) noexcept -> constant_wrapper<(L::value < R::value)> - { return {}; } - template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> - friend constexpr auto operator<=(L, R) noexcept -> constant_wrapper<(L::value <= R::value)> - { return {}; } - template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> - friend constexpr auto operator==(L, R) noexcept -> constant_wrapper<(L::value == R::value)> - { return {}; } - template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> - friend constexpr auto operator!=(L, R) noexcept -> constant_wrapper<(L::value != R::value)> - { return {}; } - template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> - friend constexpr auto operator>(L, R) noexcept -> constant_wrapper<(L::value > R::value)> - { return {}; } - template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> - friend constexpr auto operator>=(L, R) noexcept -> constant_wrapper<(L::value >= R::value)> - { return {}; } - - template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> - friend constexpr auto operator,(L, R) noexcept = delete; - template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> - friend constexpr auto operator->*(L, R) noexcept -> constant_wrapper*(R::value)> - { return {}; } - - // call and index - template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@... Args> - constexpr auto operator()(this T, Args...) noexcept - requires requires(Args...) { constant_wrapper(); } - { return constant_wrapper{}; } - template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@... Args> - constexpr auto operator[](this T, Args...) noexcept - -> constant_wrapper<(T::value[Args::value...])> + template<@\exposconcept{constexpr-param}@ T> + friend constexpr auto operator~(T) noexcept -> constant_wrapper<(~T::value)> { return {}; } - - // pseudo-mutators - template<@\exposconcept{constexpr-param}@ T> - constexpr auto operator++(this T) noexcept - requires requires(T::value_type x) { ++x; } - { return constant_wrapper<[] { auto c = T::value; return ++c; }()>{}; } - template<@\exposconcept{constexpr-param}@ T> - constexpr auto operator++(this T, int) noexcept - requires requires(T::value_type x) { x++; } - { return constant_wrapper<[] { auto c = T::value; return c++; }()>{}; } - - template<@\exposconcept{constexpr-param}@ T> - constexpr auto operator--(this T) noexcept - requires requires(T::value_type x) { --x; } - { return constant_wrapper<[] { auto c = T::value; return --c; }()>{}; } - template<@\exposconcept{constexpr-param}@ T> - constexpr auto operator--(this T, int) noexcept - requires requires(T::value_type x) { x--; } - { return constant_wrapper<[] { auto c = T::value; return c--; }()>{}; } - - template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@ R> - constexpr auto operator+=(this T, R) noexcept - requires requires(T::value_type x) { x += R::value; } - { return constant_wrapper<[] { auto v = T::value; return v += R::value; }()>{}; } - template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@ R> - constexpr auto operator-=(this T, R) noexcept - requires requires(T::value_type x) { x -= R::value; } - { return constant_wrapper<[] { auto v = T::value; return v -= R::value; }()>{}; } - template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@ R> - constexpr auto operator*=(this T, R) noexcept - requires requires(T::value_type x) { x *= R::value; } - { return constant_wrapper<[] { auto v = T::value; return v *= R::value; }()>{}; } - template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@ R> - constexpr auto operator/=(this T, R) noexcept - requires requires(T::value_type x) { x /= R::value; } - { return constant_wrapper<[] { auto v = T::value; return v /= R::value; }()>{}; } - template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@ R> - constexpr auto operator%=(this T, R) noexcept - requires requires(T::value_type x) { x %= R::value; } - { return constant_wrapper<[] { auto v = T::value; return v %= R::value; }()>{}; } - template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@ R> - constexpr auto operator&=(this T, R) noexcept - requires requires(T::value_type x) { x &= R::value; } - { return constant_wrapper<[] { auto v = T::value; return v &= R::value; }()>{}; } - template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@ R> - constexpr auto operator|=(this T, R) noexcept - requires requires(T::value_type x) { x |= R::value; } - { return constant_wrapper<[] { auto v = T::value; return v |= R::value; }()>{}; } - template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@ R> - constexpr auto operator^=(this T, R) noexcept - requires requires(T::value_type x) { x ^= R::value; } - { return constant_wrapper<[] { auto v = T::value; return v ^= R::value; }()>{}; } - template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@ R> - constexpr auto operator<<=(this T, R) noexcept - requires requires(T::value_type x) { x <<= R::value; } - { return constant_wrapper<[] { auto v = T::value; return v <<= R::value; }()>{}; } - template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@ R> - constexpr auto operator>>=(this T, R) noexcept - requires requires(T::value_type x) { x >>= R::value; } - { return constant_wrapper<[] { auto v = T::value; return v >>= R::value; }()>{}; } -}; - -template<@\exposid{cw-fixed-value}@ X, class> -struct constant_wrapper : cw-operators { - static constexpr const auto & value = X.@\exposid{data}@; - using type = constant_wrapper; - using value_type = typename decltype(X)::@\exposid{type}@; - - template<@\exposconcept{constexpr-param}@ R> - constexpr auto operator=(R) const noexcept - requires requires(value_type x) { x = R::value; } - { return constant_wrapper<[] { auto v = value; return v = R::value; }()>{}; } - - constexpr operator decltype(auto)() const noexcept { return value; } -}; + template<@\exposconcept{constexpr-param}@ T> + friend constexpr auto operator!(T) noexcept -> constant_wrapper<(!T::value)> + { return {}; } + template<@\exposconcept{constexpr-param}@ T> + friend constexpr auto operator&(T) noexcept -> constant_wrapper<(&T::value)> + { return {}; } + template<@\exposconcept{constexpr-param}@ T> + friend constexpr auto operator*(T) noexcept -> constant_wrapper<(*T::value)> + { return {}; } + + // binary operators + template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> + friend constexpr auto operator+(L, R) noexcept -> constant_wrapper<(L::value + R::value)> + { return {}; } + template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> + friend constexpr auto operator-(L, R) noexcept -> constant_wrapper<(L::value - R::value)> + { return {}; } + template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> + friend constexpr auto operator*(L, R) noexcept -> constant_wrapper<(L::value * R::value)> + { return {}; } + template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> + friend constexpr auto operator/(L, R) noexcept -> constant_wrapper<(L::value / R::value)> + { return {}; } + template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> + friend constexpr auto operator%(L, R) noexcept -> constant_wrapper<(L::value % R::value)> + { return {}; } + + template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> + friend constexpr auto operator<<(L, R) noexcept -> constant_wrapper<(L::value << R::value)> + { return {}; } + template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> + friend constexpr auto operator>>(L, R) noexcept -> constant_wrapper<(L::value >> R::value)> + { return {}; } + template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> + friend constexpr auto operator&(L, R) noexcept -> constant_wrapper<(L::value & R::value)> + { return {}; } + template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> + friend constexpr auto operator|(L, R) noexcept -> constant_wrapper<(L::value | R::value)> + { return {}; } + template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> + friend constexpr auto operator^(L, R) noexcept -> constant_wrapper<(L::value ^ R::value)> + { return {}; } + + template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> + requires (!is_constructible_v || + !is_constructible_v) + friend constexpr auto operator&&(L, R) noexcept -> constant_wrapper<(L::value && R::value)> + { return {}; } + template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> + requires (!is_constructible_v || + !is_constructible_v) + friend constexpr auto operator||(L, R) noexcept -> constant_wrapper<(L::value || R::value)> + { return {}; } + + // comparisons + template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> + friend constexpr auto operator<=>(L, R) noexcept -> constant_wrapper<(L::value <=> R::value)> + { return {}; } + template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> + friend constexpr auto operator<(L, R) noexcept -> constant_wrapper<(L::value < R::value)> + { return {}; } + template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> + friend constexpr auto operator<=(L, R) noexcept -> constant_wrapper<(L::value <= R::value)> + { return {}; } + template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> + friend constexpr auto operator==(L, R) noexcept -> constant_wrapper<(L::value == R::value)> + { return {}; } + template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> + friend constexpr auto operator!=(L, R) noexcept -> constant_wrapper<(L::value != R::value)> + { return {}; } + template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> + friend constexpr auto operator>(L, R) noexcept -> constant_wrapper<(L::value > R::value)> + { return {}; } + template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> + friend constexpr auto operator>=(L, R) noexcept -> constant_wrapper<(L::value >= R::value)> + { return {}; } + + template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> + friend constexpr auto operator,(L, R) noexcept = delete; + template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> + friend constexpr auto operator->*(L, R) noexcept -> constant_wrapper*(R::value)> + { return {}; } + + // call and index + template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@... Args> + constexpr auto operator()(this T, Args...) noexcept + requires requires(Args...) { constant_wrapper(); } + { return constant_wrapper{}; } + template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@... Args> + constexpr auto operator[](this T, Args...) noexcept + -> constant_wrapper<(T::value[Args::value...])> + { return {}; } + + // pseudo-mutators + template<@\exposconcept{constexpr-param}@ T> + constexpr auto operator++(this T) noexcept + requires requires(T::value_type x) { ++x; } + { return constant_wrapper<[] { auto c = T::value; return ++c; }()>{}; } + template<@\exposconcept{constexpr-param}@ T> + constexpr auto operator++(this T, int) noexcept + requires requires(T::value_type x) { x++; } + { return constant_wrapper<[] { auto c = T::value; return c++; }()>{}; } + + template<@\exposconcept{constexpr-param}@ T> + constexpr auto operator--(this T) noexcept + requires requires(T::value_type x) { --x; } + { return constant_wrapper<[] { auto c = T::value; return --c; }()>{}; } + template<@\exposconcept{constexpr-param}@ T> + constexpr auto operator--(this T, int) noexcept + requires requires(T::value_type x) { x--; } + { return constant_wrapper<[] { auto c = T::value; return c--; }()>{}; } + + template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@ R> + constexpr auto operator+=(this T, R) noexcept + requires requires(T::value_type x) { x += R::value; } + { return constant_wrapper<[] { auto v = T::value; return v += R::value; }()>{}; } + template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@ R> + constexpr auto operator-=(this T, R) noexcept + requires requires(T::value_type x) { x -= R::value; } + { return constant_wrapper<[] { auto v = T::value; return v -= R::value; }()>{}; } + template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@ R> + constexpr auto operator*=(this T, R) noexcept + requires requires(T::value_type x) { x *= R::value; } + { return constant_wrapper<[] { auto v = T::value; return v *= R::value; }()>{}; } + template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@ R> + constexpr auto operator/=(this T, R) noexcept + requires requires(T::value_type x) { x /= R::value; } + { return constant_wrapper<[] { auto v = T::value; return v /= R::value; }()>{}; } + template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@ R> + constexpr auto operator%=(this T, R) noexcept + requires requires(T::value_type x) { x %= R::value; } + { return constant_wrapper<[] { auto v = T::value; return v %= R::value; }()>{}; } + template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@ R> + constexpr auto operator&=(this T, R) noexcept + requires requires(T::value_type x) { x &= R::value; } + { return constant_wrapper<[] { auto v = T::value; return v &= R::value; }()>{}; } + template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@ R> + constexpr auto operator|=(this T, R) noexcept + requires requires(T::value_type x) { x |= R::value; } + { return constant_wrapper<[] { auto v = T::value; return v |= R::value; }()>{}; } + template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@ R> + constexpr auto operator^=(this T, R) noexcept + requires requires(T::value_type x) { x ^= R::value; } + { return constant_wrapper<[] { auto v = T::value; return v ^= R::value; }()>{}; } + template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@ R> + constexpr auto operator<<=(this T, R) noexcept + requires requires(T::value_type x) { x <<= R::value; } + { return constant_wrapper<[] { auto v = T::value; return v <<= R::value; }()>{}; } + template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@ R> + constexpr auto operator>>=(this T, R) noexcept + requires requires(T::value_type x) { x >>= R::value; } + { return constant_wrapper<[] { auto v = T::value; return v >>= R::value; }()>{}; } + }; + + template<@\exposid{cw-fixed-value}@ X, class> + struct constant_wrapper : cw-operators { + static constexpr const auto & value = X.@\exposid{data}@; + using type = constant_wrapper; + using value_type = typename decltype(X)::@\exposid{type}@; + + template<@\exposconcept{constexpr-param}@ R> + constexpr auto operator=(R) const noexcept + requires requires(value_type x) { x = R::value; } + { return constant_wrapper<[] { auto v = value; return v = R::value; }()>{}; } + + constexpr operator decltype(auto)() const noexcept { return value; } + }; +} \end{codeblock} \pnum From fb81e35acc6f8b4f0f9827286d4460b9ed404b54 Mon Sep 17 00:00:00 2001 From: Hewill Kang Date: Tue, 23 Sep 2025 23:50:40 +0800 Subject: [PATCH 2/3] Remove trailing space --- source/meta.tex | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/source/meta.tex b/source/meta.tex index bae5f0c25a..dfa955f5ce 100644 --- a/source/meta.tex +++ b/source/meta.tex @@ -658,17 +658,17 @@ constexpr @\exposidnc{cw-fixed-value}@(@\exposidnc{type}@ v) noexcept : @\exposidnc{data}@(v) {} T @\exposidnc{data}@; // \expos }; - + template struct @\exposidnc{cw-fixed-value}@ { // \expos using @\exposidnc{type}@ = T[Extent]; // \expos constexpr @\exposidnc{cw-fixed-value}@(T (&arr)[Extent]) noexcept; T @\exposidnc{data}@[Extent]; // \expos }; - + template @\exposidnc{cw-fixed-value}@(T (&)[Extent]) -> @\exposidnc{cw-fixed-value}@; // \expos - + struct @\exposidnc{cw-operators}@ { // \expos // unary operators template<@\exposconcept{constexpr-param}@ T> @@ -689,7 +689,7 @@ template<@\exposconcept{constexpr-param}@ T> friend constexpr auto operator*(T) noexcept -> constant_wrapper<(*T::value)> { return {}; } - + // binary operators template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> friend constexpr auto operator+(L, R) noexcept -> constant_wrapper<(L::value + R::value)> @@ -706,7 +706,7 @@ template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> friend constexpr auto operator%(L, R) noexcept -> constant_wrapper<(L::value % R::value)> { return {}; } - + template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> friend constexpr auto operator<<(L, R) noexcept -> constant_wrapper<(L::value << R::value)> { return {}; } @@ -722,7 +722,7 @@ template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> friend constexpr auto operator^(L, R) noexcept -> constant_wrapper<(L::value ^ R::value)> { return {}; } - + template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> requires (!is_constructible_v || !is_constructible_v) @@ -733,7 +733,7 @@ !is_constructible_v) friend constexpr auto operator||(L, R) noexcept -> constant_wrapper<(L::value || R::value)> { return {}; } - + // comparisons template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> friend constexpr auto operator<=>(L, R) noexcept -> constant_wrapper<(L::value <=> R::value)> @@ -756,13 +756,13 @@ template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> friend constexpr auto operator>=(L, R) noexcept -> constant_wrapper<(L::value >= R::value)> { return {}; } - + template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> friend constexpr auto operator,(L, R) noexcept = delete; template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> friend constexpr auto operator->*(L, R) noexcept -> constant_wrapper*(R::value)> { return {}; } - + // call and index template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@... Args> constexpr auto operator()(this T, Args...) noexcept @@ -772,7 +772,7 @@ constexpr auto operator[](this T, Args...) noexcept -> constant_wrapper<(T::value[Args::value...])> { return {}; } - + // pseudo-mutators template<@\exposconcept{constexpr-param}@ T> constexpr auto operator++(this T) noexcept @@ -782,7 +782,7 @@ constexpr auto operator++(this T, int) noexcept requires requires(T::value_type x) { x++; } { return constant_wrapper<[] { auto c = T::value; return c++; }()>{}; } - + template<@\exposconcept{constexpr-param}@ T> constexpr auto operator--(this T) noexcept requires requires(T::value_type x) { --x; } @@ -791,7 +791,7 @@ constexpr auto operator--(this T, int) noexcept requires requires(T::value_type x) { x--; } { return constant_wrapper<[] { auto c = T::value; return c--; }()>{}; } - + template<@\exposconcept{constexpr-param}@ T, @\exposconcept{constexpr-param}@ R> constexpr auto operator+=(this T, R) noexcept requires requires(T::value_type x) { x += R::value; } @@ -833,18 +833,18 @@ requires requires(T::value_type x) { x >>= R::value; } { return constant_wrapper<[] { auto v = T::value; return v >>= R::value; }()>{}; } }; - + template<@\exposid{cw-fixed-value}@ X, class> struct constant_wrapper : cw-operators { static constexpr const auto & value = X.@\exposid{data}@; using type = constant_wrapper; using value_type = typename decltype(X)::@\exposid{type}@; - + template<@\exposconcept{constexpr-param}@ R> constexpr auto operator=(R) const noexcept requires requires(value_type x) { x = R::value; } { return constant_wrapper<[] { auto v = value; return v = R::value; }()>{}; } - + constexpr operator decltype(auto)() const noexcept { return value; } }; } From 81f95d8ea3a495c7878c8e6d6ec670467ae5bf10 Mon Sep 17 00:00:00 2001 From: Hewill Kang Date: Wed, 24 Sep 2025 00:08:20 +0800 Subject: [PATCH 3/3] Fix long line --- source/meta.tex | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/source/meta.tex b/source/meta.tex index dfa955f5ce..e4a91fde5c 100644 --- a/source/meta.tex +++ b/source/meta.tex @@ -726,18 +726,21 @@ template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> requires (!is_constructible_v || !is_constructible_v) - friend constexpr auto operator&&(L, R) noexcept -> constant_wrapper<(L::value && R::value)> - { return {}; } + friend constexpr auto operator&&(L, R) noexcept + -> constant_wrapper<(L::value && R::value)> + { return {}; } template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> requires (!is_constructible_v || !is_constructible_v) - friend constexpr auto operator||(L, R) noexcept -> constant_wrapper<(L::value || R::value)> - { return {}; } + friend constexpr auto operator||(L, R) noexcept + -> constant_wrapper<(L::value || R::value)> + { return {}; } // comparisons template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> - friend constexpr auto operator<=>(L, R) noexcept -> constant_wrapper<(L::value <=> R::value)> - { return {}; } + friend constexpr auto operator<=>(L, R) noexcept + -> constant_wrapper<(L::value <=> R::value)> + { return {}; } template<@\exposconcept{constexpr-param}@ L, @\exposconcept{constexpr-param}@ R> friend constexpr auto operator<(L, R) noexcept -> constant_wrapper<(L::value < R::value)> { return {}; }