diff --git a/cth/incl/cth/algorithm/alg_utility.hpp b/cth/incl/cth/algorithm/alg_utility.hpp index c14488f..3fa1766 100644 --- a/cth/incl/cth/algorithm/alg_utility.hpp +++ b/cth/incl/cth/algorithm/alg_utility.hpp @@ -9,7 +9,7 @@ namespace cth::ranges { struct piped_fn {}; template requires std::derived_from, piped_fn> -cxpr declauto operator|(T&& left, Fn&& fn) { +constexpr decltype(auto) operator|(T&& left, Fn&& fn) { return std::forward(fn)(std::forward(left)); } } // namespace cth::ranges @@ -29,12 +29,12 @@ struct pipe_call_closure : piped_fn { ); template requires(std::same_as, FnArgs> && ...) - explicit cxpr pipe_call_closure(CArgs&&... args) : _args{std::forward(args)...} {} + explicit constexpr pipe_call_closure(CArgs&&... args) : _args{std::forward(args)...} {} template requires std::invocable - cxpr declauto operator()(this Me&& me, T&& arg) { + constexpr decltype(auto) operator()(this Me&& me, T&& arg) { return std::apply( - [&arg](this auto&&, Args&&... args) -> declauto { + [&arg](this auto&&, Args&&... args) -> decltype(auto) { return Fn{}(std::forward(arg), std::forward(args)...); }, std::forward(me)._args diff --git a/cth/incl/cth/algorithm/views.hpp b/cth/incl/cth/algorithm/views.hpp index 60f6065..1b3f05b 100644 --- a/cth/incl/cth/algorithm/views.hpp +++ b/cth/incl/cth/algorithm/views.hpp @@ -11,12 +11,12 @@ namespace cth::views { struct to_ptr_range_fn : cth::ranges::piped_fn { template requires std::is_lvalue_reference_v> - cxpr auto operator()(Rng&& rng) const { + constexpr auto operator()(Rng&& rng) const { return std::views::transform(std::forward(rng), [](auto& element) { return &element; }); } }; -inline cxpr to_ptr_range_fn to_ptr_range; +inline constexpr to_ptr_range_fn to_ptr_range; struct split_into_fn { /** @@ -28,7 +28,7 @@ struct split_into_fn { * @return view of */ template - cxpr auto operator()(Rng&& rng, std::ranges::range_difference_t const max_chunks) const { + constexpr auto operator()(Rng&& rng, std::ranges::range_difference_t const max_chunks) const { assert(max_chunks > 0 && "cannot chunk into <= 0 chunks"); auto const rngSize = std::ranges::size(rng); @@ -38,7 +38,7 @@ struct split_into_fn { } template requires std::constructible_from, T> - cxpr auto operator()(this Fn&&, T&& chunks) { + constexpr auto operator()(this Fn&&, T&& chunks) { return ranges::pipe_call_closure< std::remove_cvref_t, std::decay_t >{std::forward(chunks)}; @@ -48,11 +48,11 @@ struct split_into_fn { /** * splits a range into <= n chunks */ -inline cxpr split_into_fn split_into; +inline constexpr split_into_fn split_into; struct drop_stride_fn { template - cxpr auto operator()( + constexpr auto operator()( Rng&& rng, std::ranges::range_difference_t const drop, std::ranges::range_difference_t const stride @@ -60,7 +60,7 @@ struct drop_stride_fn { template requires(std::constructible_from, T> && std::constructible_from , U>) - cxpr auto operator()(this Fn&&, T&& drop, U&& stride) { + constexpr auto operator()(this Fn&&, T&& drop, U&& stride) { return ranges::pipe_call_closure, std::decay_t, std::decay_t>{ std::forward(drop), std::forward(stride) @@ -68,7 +68,7 @@ struct drop_stride_fn { } }; -inline cxpr drop_stride_fn drop_stride; +inline constexpr drop_stride_fn drop_stride; struct transform_call_fn { template @@ -76,7 +76,7 @@ struct transform_call_fn { template requires(std::invocable, Args...>) - cxpr auto operator()(Rng&& rng, Call&& call, Args&&... args) const { + constexpr auto operator()(Rng&& rng, Call&& call, Args&&... args) const { return std::views::transform( std::forward(rng), [&call, &args...] < class T >(T&& element) { @@ -90,7 +90,7 @@ struct transform_call_fn { } template requires(!std::ranges::range) - cxpr auto operator()(this Fn&&, Call&& call, Args&&... args) { + constexpr auto operator()(this Fn&&, Call&& call, Args&&... args) { return ranges::pipe_call_closure, std::decay_t, std::decay_t...>{ std::forward(call), std::forward(args)... @@ -98,7 +98,7 @@ struct transform_call_fn { } }; -inline cxpr transform_call_fn transform_call; +inline constexpr transform_call_fn transform_call; } namespace cth::views { @@ -121,7 +121,7 @@ struct format_fn { * @return formattable object */ template - [[nodiscard]] cxpr auto operator()( + [[nodiscard]] constexpr auto operator()( Rng&& rng, std::string_view sep, std::string_view pre = "", @@ -129,7 +129,7 @@ struct format_fn { ) const { return format_view{std::views::all(std::forward(rng)), sep, pre, post}; } template - [[nodiscard]] cxpr auto operator()( + [[nodiscard]] constexpr auto operator()( this Me&&, std::string_view sep, std::string_view pre = "", @@ -149,17 +149,17 @@ struct format_fn { }; -inline cxpr format_fn format; +inline constexpr format_fn format; } template struct std::formatter> { using value_type = std::ranges::range_value_t; - [[nodiscard]] cxpr auto parse(std::format_parse_context& ctx) { return _formatter.parse(ctx); } + [[nodiscard]] constexpr auto parse(std::format_parse_context& ctx) { return _formatter.parse(ctx); } template - [[nodiscard]] cxpr auto format( + [[nodiscard]] constexpr auto format( cth::views::format_view& obj, FormatContext& ctx ) const { diff --git a/cth/incl/cth/exception.hpp b/cth/incl/cth/exception.hpp index 9bf8c5a..2529b47 100644 --- a/cth/incl/cth/exception.hpp +++ b/cth/incl/cth/exception.hpp @@ -24,7 +24,7 @@ enum Severity { CRITICAL, SEVERITY_SIZE, }; -[[nodiscard]] cxpr std::string_view to_string(Severity sev) { +[[nodiscard]] constexpr std::string_view to_string(Severity sev) { switch(sev) { // NOLINT(clang-diagnostic-switch-enum) case LOG: return "LOG"; @@ -59,7 +59,7 @@ struct std::formatter { namespace cth::except { class default_exception : public std::exception { template - cxpr S& addNoCpy(this S& s, std::string_view msg) noexcept { + constexpr S& addNoCpy(this S& s, std::string_view msg) noexcept { if(s._details.empty()) s._details = "DETAILS:\n"; s._details += std::format("\t{}\n", msg); @@ -82,10 +82,10 @@ class default_exception : public std::exception { ~default_exception() override = default; template - cxpr declauto add(this S&& self, std::string_view msg) noexcept { return self.addNoCpy(msg); } + constexpr decltype(auto) add(this S&& self, std::string_view msg) noexcept { return self.addNoCpy(msg); } template requires(sizeof...(Args) > 0u) - cxpr declauto add(this S& self, std::format_string f_str, Args&&... types) noexcept { + constexpr decltype(auto) add(this S& self, std::format_string f_str, Args&&... types) noexcept { return self.addNoCpy(std::format(f_str, std::forward(types)...)); } @@ -153,14 +153,14 @@ class default_exception : public std::exception { std::string _what; public: - [[nodiscard]] cxpr Severity severity() const noexcept { return _severity; } - [[nodiscard]] cxpr std::string_view details() const noexcept { return _details; } - [[nodiscard]] cxpr std::string_view msg() const noexcept { return _msg; } + [[nodiscard]] constexpr Severity severity() const noexcept { return _severity; } + [[nodiscard]] constexpr std::string_view details() const noexcept { return _details; } + [[nodiscard]] constexpr std::string_view msg() const noexcept { return _msg; } - [[nodiscard]] cxpr std::stacktrace const& stacktrace() const noexcept { return _trace; } - [[nodiscard]] cxpr std::source_location const& location() const noexcept { return _sourceLocation; } + [[nodiscard]] constexpr std::stacktrace const& stacktrace() const noexcept { return _trace; } + [[nodiscard]] constexpr std::source_location const& location() const noexcept { return _sourceLocation; } - [[nodiscard]] cxpr char const* what() const noexcept override { return _what.c_str(); } + [[nodiscard]] constexpr char const* what() const noexcept override { return _what.c_str(); } default_exception(default_exception const& other) noexcept = default; default_exception(default_exception&& other) noexcept = default; diff --git a/cth/incl/cth/hash/hash_aggregates.hpp b/cth/incl/cth/hash/hash_aggregates.hpp index 6cc8229..4e790b9 100644 --- a/cth/incl/cth/hash/hash_aggregates.hpp +++ b/cth/incl/cth/hash/hash_aggregates.hpp @@ -8,7 +8,7 @@ namespace cth::hash { template -cxpr size_t hash_aggregate(T const& t) { +constexpr size_t hash_aggregate(T const& t) { return std::apply( [] < class... Args >(Args&&... args) { return hash::combine(std::forward(args)...); }, boost::pfr::structure_tie(t) @@ -19,5 +19,5 @@ cxpr size_t hash_aggregate(T const& t) { #define CTH_HASH_AGGREGATE(type) \ template<> \ struct std::hash { \ - cxpr size_t operator()(type const& x) const noexcept { return cth::hash::hash_aggregate(x); } \ + constexpr size_t operator()(type const& x) const noexcept { return cth::hash::hash_aggregate(x); } \ }; diff --git a/cth/incl/cth/hash/hash_general.hpp b/cth/incl/cth/hash/hash_general.hpp index 1ad52d0..571f19a 100644 --- a/cth/incl/cth/hash/hash_general.hpp +++ b/cth/incl/cth/hash/hash_general.hpp @@ -8,14 +8,14 @@ namespace cth::hash { namespace dev { template - cxpr size_t& combine(size_t& seed, T const& v) { + constexpr size_t& combine(size_t& seed, T const& v) { // from: https://stackoverflow.com/a/57595105 return seed ^= std::hash{}(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } } template -cxpr size_t combine(Args&&... args) { +constexpr size_t combine(Args&&... args) { size_t seed = 0; (dev::combine(seed, std::forward(args)), ...); @@ -23,7 +23,7 @@ cxpr size_t combine(Args&&... args) { } template requires(std::ranges::range) -cxpr size_t rng(Rng&& rng) { +constexpr size_t rng(Rng&& rng) { size_t seed = 0; for(auto const& v : std::forward(rng)) dev::combine(seed, v); diff --git a/cth/incl/cth/io/console.hpp b/cth/incl/cth/io/console.hpp index 1fd92ad..b44e564 100644 --- a/cth/incl/cth/io/console.hpp +++ b/cth/incl/cth/io/console.hpp @@ -179,7 +179,7 @@ template namespace cth::io::dev { -inline cxpr size_t MAX_STACK_SIZE = 16; +inline constexpr size_t MAX_STACK_SIZE = 16; enum Cursor_Ids { // cursor codes diff --git a/cth/incl/cth/io/file.hpp b/cth/incl/cth/io/file.hpp index 0cd83ce..51005c1 100644 --- a/cth/incl/cth/io/file.hpp +++ b/cth/incl/cth/io/file.hpp @@ -7,10 +7,10 @@ #include namespace cth::io::file { -cxpr uintmax_t BYTE = 1; -cxpr uintmax_t KB = BYTE * 1024; -cxpr uintmax_t MB = KB * 1024; -cxpr uintmax_t GB = MB * 1024; +constexpr uintmax_t BYTE = 1; +constexpr uintmax_t KB = BYTE * 1024; +constexpr uintmax_t MB = KB * 1024; +constexpr uintmax_t GB = MB * 1024; template uintmax_t size_in(std::filesystem::path const& path) { @@ -20,7 +20,7 @@ uintmax_t size_in(std::filesystem::path const& path) { return file_size(path) / Divisor; } -cxpr size_t DEFAULT_CHOP_BUFFER_SIZE = 0xfff; +constexpr size_t DEFAULT_CHOP_BUFFER_SIZE = 0xfff; template std::vector chop(std::filesystem::path const& path, D delimiter) { diff --git a/cth/incl/cth/io/keybd/keys.hpp b/cth/incl/cth/io/keybd/keys.hpp index 75916ac..4c9fe33 100644 --- a/cth/incl/cth/io/keybd/keys.hpp +++ b/cth/incl/cth/io/keybd/keys.hpp @@ -129,7 +129,7 @@ consteval auto keys_size() { return static_cast(Key::ENUM_LAST_VALUE) + /** * converts the Key to UTF-8 string symbol */ -cxpr std::string_view to_utf8_string(Key key) { +constexpr std::string_view to_utf8_string(Key key) { switch(key) { // Alphabetical keys case Key::A: return "A"; diff --git a/cth/incl/cth/io/log.hpp b/cth/incl/cth/io/log.hpp index abcb76f..2186ec0 100644 --- a/cth/incl/cth/io/log.hpp +++ b/cth/incl/cth/io/log.hpp @@ -27,7 +27,7 @@ inline bool colored = true; inline io::col_stream logStream{std::cerr}; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) inline std::mutex logMtx; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) -cxpr io::TextColor text_color(cth::except::Severity severity) { +constexpr io::TextColor text_color(cth::except::Severity severity) { switch(severity) { case cth::except::LOG: return io::TextColor::WHITE; case cth::except::Severity::INFO: return io::TextColor::DARK_CYAN; @@ -39,7 +39,7 @@ cxpr io::TextColor text_color(cth::except::Severity severity) { } } -[[nodiscard]] cxpr std::string_view label(cth::except::Severity severity) { +[[nodiscard]] constexpr std::string_view label(cth::except::Severity severity) { switch(severity) { case cth::except::Severity::LOG: return "[LOG]"; case cth::except::Severity::INFO: return "[INFO]"; diff --git a/cth/incl/cth/macro.hpp b/cth/incl/cth/macro.hpp index 9584d2e..ad4aded 100644 --- a/cth/incl/cth/macro.hpp +++ b/cth/incl/cth/macro.hpp @@ -1,7 +1,4 @@ #pragma once -#define cxpr constexpr -#define cval consteval -#define declauto decltype(auto) #define CPT(concept) \ [] < concept > {} diff --git a/cth/incl/cth/meta/inl/ranges.inl b/cth/incl/cth/meta/inl/ranges.inl index 287ddb4..8baf7f8 100644 --- a/cth/incl/cth/meta/inl/ranges.inl +++ b/cth/incl/cth/meta/inl/ranges.inl @@ -6,13 +6,13 @@ namespace cth::mta { template -[[nodiscard]] cval size_t dimensions(size_t max) { +[[nodiscard]] consteval size_t dimensions(size_t max) { return trait_count(max); } namespace dev { template - cval auto md_range_value() { + consteval auto md_range_value() { static constexpr auto RANK = mta::dimensions(D); return repeat_trait{}; diff --git a/cth/incl/cth/meta/inl/traits.inl b/cth/incl/cth/meta/inl/traits.inl index fd179ec..66ddc0a 100644 --- a/cth/incl/cth/meta/inl/traits.inl +++ b/cth/incl/cth/meta/inl/traits.inl @@ -8,7 +8,7 @@ namespace cth::mta { namespace dev { template class Trait> - cval size_t trait_count_helper(size_t max, size_t n = 0) { + consteval size_t trait_count_helper(size_t max, size_t n = 0) { if constexpr(!simple_trait_applicable) return n; else { @@ -20,11 +20,11 @@ namespace dev { } template class Trait> -[[nodiscard]] cval size_t trait_count(size_t max_depth) { return dev::trait_count_helper(max_depth); } +[[nodiscard]] consteval size_t trait_count(size_t max_depth) { return dev::trait_count_helper(max_depth); } namespace dev { template class Trait> - cval size_t cpt_count(size_t max_depth, size_t n = 0) { + consteval size_t cpt_count(size_t max_depth, size_t n = 0) { if(n >= max_depth) return n; @@ -43,7 +43,7 @@ namespace dev { } template class Trait> -[[nodiscard]] cval size_t cpt_count(size_t max_depth) { +[[nodiscard]] consteval size_t cpt_count(size_t max_depth) { return dev::cpt_count(max_depth); } diff --git a/cth/incl/cth/meta/md.hpp b/cth/incl/cth/meta/md.hpp index ce6b4d0..20e57d9 100644 --- a/cth/incl/cth/meta/md.hpp +++ b/cth/incl/cth/meta/md.hpp @@ -14,7 +14,7 @@ namespace cth::mta { * @return std::extents */ template -[[nodiscard]] cval auto mdextent() { +[[nodiscard]] consteval auto mdextent() { return std::apply( [] < class... Args >(Args... args) { return std::extents(), Extent)...>{args...}; diff --git a/cth/incl/cth/meta/ranges.hpp b/cth/incl/cth/meta/ranges.hpp index 386dbbd..ad845d2 100644 --- a/cth/incl/cth/meta/ranges.hpp +++ b/cth/incl/cth/meta/ranges.hpp @@ -18,7 +18,7 @@ namespace cth::mta { * @param max optional max search depth */ template -cval size_t dimensions(size_t max = MAX_DEPTH); +consteval size_t dimensions(size_t max = MAX_DEPTH); /** * @brief checks if @ref Rng is of at least @ref D dimensions @@ -31,7 +31,7 @@ concept md_range = dimensions(D) == D; namespace dev { template - cval auto md_range_value(); + consteval auto md_range_value(); } @@ -90,7 +90,7 @@ concept viewable_rng = std::ranges::viewable_range || (std::ranges::viewable_range> && requires(Rng rng) { mta::rcvr_t{rng}; }); template -auto cxpr to_viewable(Rng&& rng) { +constexpr auto to_viewable(Rng&& rng) { if constexpr(std::ranges::viewable_range) return std::forward(rng); else { diff --git a/cth/incl/cth/meta/traits.hpp b/cth/incl/cth/meta/traits.hpp index f736a58..a761ecc 100644 --- a/cth/incl/cth/meta/traits.hpp +++ b/cth/incl/cth/meta/traits.hpp @@ -31,10 +31,10 @@ template class Trait, class T> using repeat_trait_t = repeat_trait::type; template class Trait> -[[nodiscard]] cval size_t trait_count(size_t max_depth = MAX_DEPTH); +[[nodiscard]] consteval size_t trait_count(size_t max_depth = MAX_DEPTH); template class Trait> -[[nodiscard]] cval size_t cpt_count(size_t max_depth = MAX_DEPTH); +[[nodiscard]] consteval size_t cpt_count(size_t max_depth = MAX_DEPTH); /** * should not be used, use std::forward_like instead diff --git a/cth/incl/cth/meta/tuple.hpp b/cth/incl/cth/meta/tuple.hpp index fc8adf9..d933da2 100644 --- a/cth/incl/cth/meta/tuple.hpp +++ b/cth/incl/cth/meta/tuple.hpp @@ -30,13 +30,13 @@ namespace cth::mta { namespace dev { template - cval auto n_tuple_gen(T fill, std::index_sequence) { return std::tuple{(mta::zero(I), fill)...}; } + consteval auto n_tuple_gen(T fill, std::index_sequence) { return std::tuple{(mta::zero(I), fill)...}; } } template -[[nodiscard]] cval auto n_tuple(T fill = {}) { return dev::n_tuple_gen(fill, std::make_index_sequence()); } +[[nodiscard]] consteval auto n_tuple(T fill = {}) { return dev::n_tuple_gen(fill, std::make_index_sequence()); } template -[[nodiscard]] cval auto n_tuple() { return n_tuple(0); } +[[nodiscard]] consteval auto n_tuple() { return n_tuple(0); } } diff --git a/cth/incl/cth/meta/utility.hpp b/cth/incl/cth/meta/utility.hpp index ce2aaf0..8494c16 100644 --- a/cth/incl/cth/meta/utility.hpp +++ b/cth/incl/cth/meta/utility.hpp @@ -24,15 +24,15 @@ using type_of_t = decltype(TraitValue)::type; namespace cth::mta { template -size_t cval zero() { return 0; } +consteval size_t zero() { return 0; } template -size_t cval zero(T) { return zero(); } +consteval size_t zero(T) { return zero(); } template -size_t cval zero() { return mta::zero(Val); } +consteval size_t zero() { return mta::zero(Val); } template -declauto copy_if(T&& value) { +decltype(auto) copy_if(T&& value) { if constexpr(Copy) return std::remove_cvref_t{value}; else diff --git a/cth/incl/cth/numeric.hpp b/cth/incl/cth/numeric.hpp index c406810..787d82d 100644 --- a/cth/incl/cth/numeric.hpp +++ b/cth/incl/cth/numeric.hpp @@ -13,7 +13,7 @@ namespace cth { // ------------------ namespace num { template - [[nodiscard]] cxpr auto abs_diff(T t, U u) { + [[nodiscard]] constexpr auto abs_diff(T t, U u) { using base_t = std::conditional_t< std::unsigned_integral && std::unsigned_integral, std::conditional_t<(sizeof(T) > sizeof(U)), T, U>, @@ -34,15 +34,15 @@ namespace num { * \param b excluded */ template - [[nodiscard]] cxpr T cycle(T x, T a, T b); + [[nodiscard]] constexpr T cycle(T x, T a, T b); template - [[nodiscard]] cxpr T exp(T x, T precision = static_cast(1e-6)); + [[nodiscard]] constexpr T exp(T x, T precision = static_cast(1e-6)); template - [[nodiscard]] cxpr T heron_sqrt(T x, T precision = static_cast(1e-6)); + [[nodiscard]] constexpr T heron_sqrt(T x, T precision = static_cast(1e-6)); - [[nodiscard]] cxpr auto map(auto x, auto in_a, auto in_b, auto out_a, auto out_b); + [[nodiscard]] constexpr auto map(auto x, auto in_a, auto in_b, auto out_a, auto out_b); template [[nodiscard]] T dist(T x1, T y1, T x2, T y2); @@ -50,20 +50,20 @@ namespace num { /** * @brief checks if @ref x is in [ @ref a, @ref b) */ - [[nodiscard]] cxpr bool in(auto x, auto a, auto b); + [[nodiscard]] constexpr bool in(auto x, auto a, auto b); /** * @brief in for two values */ template - [[nodiscard]] cxpr bool in(T x, T a_x, T b_x, U y, U a_y, U b_y); + [[nodiscard]] constexpr bool in(T x, T a_x, T b_x, U y, U a_y, U b_y); /** * @brief calculates the unsigned integral power of an arithmetic base * @attention power must be >= 0 */ template - [[nodiscard]] cxpr T pow(T base, std::integral auto power); + [[nodiscard]] constexpr T pow(T base, std::integral auto power); } // namespace num // ----------------------- @@ -72,7 +72,7 @@ namespace num { namespace num { template - [[nodiscard]] cxpr T cycle(T x, T a, T b) { + [[nodiscard]] constexpr T cycle(T x, T a, T b) { CTH_CRITICAL(b <= a, "invalid input: ({0}) a < b ({1}) required", a, b) {} T const off = (x - a) % (b - a); return off < 0 ? b + off : a + off; @@ -80,11 +80,11 @@ namespace num { template requires(Size > 0) - cval bool power_2() { return Size == 0 || ((Size & (Size - 1)) == 0); } + consteval bool power_2() { return Size == 0 || ((Size & (Size - 1)) == 0); } template requires(Multiple > 0) - cxpr auto align_to(std::integral auto unaligned) { + constexpr auto align_to(std::integral auto unaligned) { if constexpr((Multiple & (Multiple - 1)) == 0) return (unaligned + (Multiple - 1)) & ~(Multiple - 1); @@ -93,10 +93,10 @@ namespace num { } template - cxpr auto align_to(std::integral auto unaligned) { return cth::num::align_to(unaligned); } + constexpr auto align_to(std::integral auto unaligned) { return cth::num::align_to(unaligned); } template - [[nodiscard]] cxpr T exp(T x, T precision) { + [[nodiscard]] constexpr T exp(T x, T precision) { uint32_t n = 1; T result = 1, term = x; while(std::abs(term) > precision) { @@ -108,7 +108,7 @@ namespace num { } template - [[nodiscard]] cxpr T heron_sqrt(T x, T precision) { + [[nodiscard]] constexpr T heron_sqrt(T x, T precision) { CTH_CRITICAL(x < 0, "heronSqrt: x ({}) >= 0 required", x) {} T val = x * static_cast(0.5); @@ -118,7 +118,7 @@ namespace num { return val; } - [[nodiscard]] cxpr auto map(auto x, auto in_a, auto in_b, auto out_a, auto out_b) { + [[nodiscard]] constexpr auto map(auto x, auto in_a, auto in_b, auto out_a, auto out_b) { return out_a + (out_b - out_a) * ((x - in_a) / (in_b - in_a)); } @@ -128,20 +128,20 @@ namespace num { return static_cast(std::sqrt(dx * dx + dy * dy)); } - [[nodiscard]] cxpr bool in(auto x, auto a, auto b) { + [[nodiscard]] constexpr bool in(auto x, auto a, auto b) { assert(a < b && "invalid input: a <= b required"); return a <= x && x < b; } - [[nodiscard]] cxpr bool in_inc(auto x, auto a, auto b) { return a <= x && x <= b; } + [[nodiscard]] constexpr bool in_inc(auto x, auto a, auto b) { return a <= x && x <= b; } template - [[nodiscard]] cxpr bool in(T x, T a_x, T b_x, U y, U a_y, U b_y) { + [[nodiscard]] constexpr bool in(T x, T a_x, T b_x, U y, U a_y, U b_y) { return num::in(x, a_x, b_x) && num::in(y, a_y, b_y); } /* template - [[nodiscard]] cxpr T sqam(T base, U power, V mod) { + [[nodiscard]] constexpr T sqam(T base, U power, V mod) { CTH_CRITICAL(mod < 0, "invalid input: mod ({}) > 0 required", mod) {} auto bitArr = bits::toBitArr(power); @@ -157,7 +157,7 @@ namespace num { }*/ template - [[nodiscard]] cxpr T pow(T base, std::integral auto power) { + [[nodiscard]] constexpr T pow(T base, std::integral auto power) { CTH_CRITICAL(power < 0, "power must be > 0") {} T result{1}; while(power > 0) { @@ -181,21 +181,21 @@ namespace expr::num { } template - [[nodiscard]] cxpr T heron_sqrt(T x, T const precision = static_cast(1e-6)) { + [[nodiscard]] constexpr T heron_sqrt(T x, T const precision = static_cast(1e-6)) { return cth::num::heron_sqrt(x, precision); } template - [[nodiscard]] cxpr T cycle(T x, T a, T b) { return cth::num::cycle(x, a, b); } + [[nodiscard]] constexpr T cycle(T x, T a, T b) { return cth::num::cycle(x, a, b); } template - [[nodiscard]] cxpr T dist(T x1, T y1, T x2, T y2, T const precision = static_cast(1e-6)) { + [[nodiscard]] constexpr T dist(T x1, T y1, T x2, T y2, T const precision = static_cast(1e-6)) { auto const dx = static_cast(x2 - x1), dy = static_cast(y2 - y1); return static_cast(cth::num::heron_sqrt(dx * dx + dy * dy, precision)); } - [[nodiscard]] cxpr bool in_inc(auto x, auto a, auto b) { return cth::num::in_inc(x, a, b); } - [[nodiscard]] cxpr bool in(auto x, auto a, auto b) { return cth::num::in(x, a, b); } + [[nodiscard]] constexpr bool in_inc(auto x, auto a, auto b) { return cth::num::in_inc(x, a, b); } + [[nodiscard]] constexpr bool in(auto x, auto a, auto b) { return cth::num::in(x, a, b); } template [[nodiscard]] constexpr bool in(T x, T a_x, T b_x, T y, T a_y, T b_y) { @@ -203,10 +203,10 @@ namespace expr::num { } // template - // [[nodiscard]] cxpr T sqam(T base, U power, V mod) { return cth::num::sqam(base, power, mod); } + // [[nodiscard]] constexpr T sqam(T base, U power, V mod) { return cth::num::sqam(base, power, mod); } template - [[nodiscard]] cxpr T pow(T base, std::unsigned_integral auto power) { return cth::num::pow(base, power); } + [[nodiscard]] constexpr T pow(T base, std::unsigned_integral auto power) { return cth::num::pow(base, power); } } } diff --git a/cth/incl/cth/ptr/not_null.hpp b/cth/incl/cth/ptr/not_null.hpp index c6f1423..3a1c5e8 100644 --- a/cth/incl/cth/ptr/not_null.hpp +++ b/cth/incl/cth/ptr/not_null.hpp @@ -15,30 +15,30 @@ class not_null { public: using null_t = decltype(Null); using type = T; - static cxpr bool NULL_OP = std::same_as; + static constexpr bool NULL_OP = std::same_as; private: - static cxpr bool CPY_CTOR = std::is_copy_constructible_v; - static cxpr bool CPY_ASSIGN = std::is_copy_assignable_v; - static cxpr bool MOVE_CTOR = std::is_move_constructible_v; - static cxpr bool MOVE_ASSIGN = std::is_move_assignable_v; + static constexpr bool CPY_CTOR = std::is_copy_constructible_v; + static constexpr bool CPY_ASSIGN = std::is_copy_assignable_v; + static constexpr bool MOVE_CTOR = std::is_move_constructible_v; + static constexpr bool MOVE_ASSIGN = std::is_move_assignable_v; - static cxpr bool NULL_CPY_CTOR = NULL_OP && CPY_CTOR; - static cxpr bool NULL_CPY_ASSIGN = NULL_OP && CPY_ASSIGN; - static cxpr bool NULL_MOVE_CTOR = NULL_OP && MOVE_CTOR; - static cxpr bool NULL_MOVE_ASSIGN = NULL_OP && MOVE_ASSIGN; + static constexpr bool NULL_CPY_CTOR = NULL_OP && CPY_CTOR; + static constexpr bool NULL_CPY_ASSIGN = NULL_OP && CPY_ASSIGN; + static constexpr bool NULL_MOVE_CTOR = NULL_OP && MOVE_CTOR; + static constexpr bool NULL_MOVE_ASSIGN = NULL_OP && MOVE_ASSIGN; - static cxpr bool NOEXCEPT_MOVE_CTOR = std::is_nothrow_move_constructible_v; - static cxpr bool NOEXCEPT_MOVE_ASSIGN = std::is_nothrow_move_assignable_v; - static cxpr bool NOEXCEPT_COPY_CTOR = std::is_nothrow_copy_constructible_v; - static cxpr bool NOEXCEPT_ASSIGN = std::is_nothrow_copy_assignable_v; + static constexpr bool NOEXCEPT_MOVE_CTOR = std::is_nothrow_move_constructible_v; + static constexpr bool NOEXCEPT_MOVE_ASSIGN = std::is_nothrow_move_assignable_v; + static constexpr bool NOEXCEPT_COPY_CTOR = std::is_nothrow_copy_constructible_v; + static constexpr bool NOEXCEPT_ASSIGN = std::is_nothrow_copy_assignable_v; - static cxpr bool GET_COPY = std::is_trivially_copyable_v && sizeof(T) <= 16; - static cxpr bool ADAPT_RELEASE = Adapt && cth::mta::has_release; - static cxpr bool ADAPT_GET = Adapt && cth::mta::has_get; + static constexpr bool GET_COPY = std::is_trivially_copyable_v && sizeof(T) <= 16; + static constexpr bool ADAPT_RELEASE = Adapt && cth::mta::has_release; + static constexpr bool ADAPT_GET = Adapt && cth::mta::has_get; - static cxpr bool NOEXCEPT_CHECK_VAL = COMPILATION_MODE != CompilationMode::DEBUG; - static cxpr bool RELEASE_VAL_NOEXCEPT = NOEXCEPT_ASSIGN && NOEXCEPT_MOVE_CTOR; + static constexpr bool NOEXCEPT_CHECK_VAL = COMPILATION_MODE != CompilationMode::DEBUG; + static constexpr bool RELEASE_VAL_NOEXCEPT = NOEXCEPT_ASSIGN && NOEXCEPT_MOVE_CTOR; static CTH_RELEASE_CONSTEXPR void checkVal(T const& obj) noexcept(NOEXCEPT_CHECK_VAL) { CTH_CRITICAL(obj == Null, "obj must not be Null") {} @@ -49,70 +49,70 @@ class not_null { _obj{std::move(obj)} { not_null::checkVal(_obj); } template requires(std::convertible_to && !std::same_as) - cxpr not_null(not_null const& other) noexcept(NOEXCEPT_COPY_CTOR) requires(CPY_CTOR) + constexpr not_null(not_null const& other) noexcept(NOEXCEPT_COPY_CTOR) requires(CPY_CTOR) : _obj{other.get_val()} {} - cxpr ~not_null() = default; + constexpr ~not_null() = default; - [[nodiscard]] cxpr T release_val() noexcept(RELEASE_VAL_NOEXCEPT) { + [[nodiscard]] constexpr T release_val() noexcept(RELEASE_VAL_NOEXCEPT) { T obj{std::move(_obj)}; _obj = Null; return obj; } - [[nodiscard]] cxpr auto release() noexcept( + [[nodiscard]] constexpr auto release() noexcept( (!ADAPT_RELEASE && RELEASE_VAL_NOEXCEPT) || (ADAPT_RELEASE && noexcept(std::declval().release())) ) { - if cxpr(!ADAPT_RELEASE) + if constexpr(!ADAPT_RELEASE) return release_val(); return _obj.release(); } - cxpr void swap(not_null& other) noexcept { std::swap(_obj, other._obj); } + constexpr void swap(not_null& other) noexcept { std::swap(_obj, other._obj); } - cxpr not_null(not_null const& other) requires(CPY_CTOR) = default; - cxpr not_null(not_null const& other) requires(!CPY_CTOR) = delete; - cxpr not_null& operator=(not_null const& other) requires(CPY_ASSIGN) = default; - cxpr not_null& operator=(not_null const& other) requires(!CPY_ASSIGN) = delete; + constexpr not_null(not_null const& other) requires(CPY_CTOR) = default; + constexpr not_null(not_null const& other) requires(!CPY_CTOR) = delete; + constexpr not_null& operator=(not_null const& other) requires(CPY_ASSIGN) = default; + constexpr not_null& operator=(not_null const& other) requires(!CPY_ASSIGN) = delete; - cxpr not_null(not_null&& other) noexcept(NOEXCEPT_MOVE_CTOR) requires(MOVE_CTOR) = default; - cxpr not_null(not_null&& other) noexcept(NOEXCEPT_MOVE_CTOR) requires(!MOVE_CTOR) = delete; - cxpr not_null& operator=(not_null&& other) noexcept(NOEXCEPT_MOVE_ASSIGN) requires(MOVE_ASSIGN) = default; - cxpr not_null& operator=(not_null&& other) noexcept(NOEXCEPT_MOVE_ASSIGN) requires(!MOVE_ASSIGN) = delete; + constexpr not_null(not_null&& other) noexcept(NOEXCEPT_MOVE_CTOR) requires(MOVE_CTOR) = default; + constexpr not_null(not_null&& other) noexcept(NOEXCEPT_MOVE_CTOR) requires(!MOVE_CTOR) = delete; + constexpr not_null& operator=(not_null&& other) noexcept(NOEXCEPT_MOVE_ASSIGN) requires(MOVE_ASSIGN) = default; + constexpr not_null& operator=(not_null&& other) noexcept(NOEXCEPT_MOVE_ASSIGN) requires(!MOVE_ASSIGN) = delete; - cxpr not_null(null_t const&) requires(!NULL_CPY_CTOR) = delete; - cxpr not_null& operator=(null_t const&) requires(NULL_CPY_ASSIGN) = delete; - cxpr not_null(null_t&& other) requires(!NULL_MOVE_CTOR) = delete; - cxpr not_null& operator=(null_t&& other) requires(!NULL_MOVE_ASSIGN) = delete; + constexpr not_null(null_t const&) requires(!NULL_CPY_CTOR) = delete; + constexpr not_null& operator=(null_t const&) requires(NULL_CPY_ASSIGN) = delete; + constexpr not_null(null_t&& other) requires(!NULL_MOVE_CTOR) = delete; + constexpr not_null& operator=(null_t&& other) requires(!NULL_MOVE_ASSIGN) = delete; - [[nodiscard]] cxpr bool operator==(null_t) const requires(!NULL_OP) = delete; - [[nodiscard]] cxpr bool operator!=(null_t) const requires(!NULL_OP) = delete; - [[nodiscard]] cxpr bool operator<(null_t) const requires(!NULL_OP) = delete; - [[nodiscard]] cxpr bool operator>(null_t) const requires(!NULL_OP) = delete; - [[nodiscard]] cxpr bool operator<=(null_t) const requires(!NULL_OP) = delete; - [[nodiscard]] cxpr bool operator>=(null_t) const requires(!NULL_OP) = delete; + [[nodiscard]] constexpr bool operator==(null_t) const requires(!NULL_OP) = delete; + [[nodiscard]] constexpr bool operator!=(null_t) const requires(!NULL_OP) = delete; + [[nodiscard]] constexpr bool operator<(null_t) const requires(!NULL_OP) = delete; + [[nodiscard]] constexpr bool operator>(null_t) const requires(!NULL_OP) = delete; + [[nodiscard]] constexpr bool operator<=(null_t) const requires(!NULL_OP) = delete; + [[nodiscard]] constexpr bool operator>=(null_t) const requires(!NULL_OP) = delete; private: T _obj; public: - [[nodiscard]] cxpr auto get() const noexcept { + [[nodiscard]] constexpr auto get() const noexcept { if constexpr(ADAPT_GET) return _obj.get(); else return get_val(); } - [[nodiscard]] cxpr std::conditional_t get_val() const noexcept { return _obj; } - [[nodiscard]] cxpr declauto operator->() const { return get(); } - [[nodiscard]] cxpr declauto operator*() const requires(cth::mta::has_deref) { return *get(); } + [[nodiscard]] constexpr std::conditional_t get_val() const noexcept { return _obj; } + [[nodiscard]] constexpr decltype(auto) operator->() const { return get(); } + [[nodiscard]] constexpr decltype(auto) operator*() const requires(cth::mta::has_deref) { return *get(); } }; template -cxpr void swap(not_null& left, not_null& right) noexcept { left.swap(right); } +constexpr void swap(not_null& left, not_null& right) noexcept { left.swap(right); } template [[nodiscard]] auto make_not_null(T&& t) noexcept { @@ -120,32 +120,32 @@ template } template -[[nodiscard]] cxpr bool +[[nodiscard]] constexpr bool operator==(not_null const& ptr, not_null const& other) { return std::equal_to{}(ptr.get(), other.get()); } template -[[nodiscard]] cxpr bool +[[nodiscard]] constexpr bool operator!=(not_null const& left, not_null const& right) { return std::not_equal_to{}(left.get(), right.get()); } template -[[nodiscard]] cxpr bool +[[nodiscard]] constexpr bool operator<(not_null const& left, not_null const& right) { return std::less{}(left.get(), right.get()); } template -[[nodiscard]] cxpr bool +[[nodiscard]] constexpr bool operator>(not_null const& left, not_null const& right) { return std::greater{}(left.get(), right.get()); } template -[[nodiscard]] cxpr bool +[[nodiscard]] constexpr bool operator<=(not_null const& left, not_null const& right) { return std::less_equal{}(left.get(), right.get()); } template -[[nodiscard]] cxpr bool +[[nodiscard]] constexpr bool operator>=(not_null const& left, not_null const& right) { return std::greater_equal{}(left.get(), right.get()); } @@ -158,29 +158,29 @@ std::ostream& operator<<(std::ostream& os, not_null const& not_n } template requires(!not_null::NULL_OP) -[[nodiscard]] cxpr bool operator==(not_null const&, decltype(Null)) = delete; +[[nodiscard]] constexpr bool operator==(not_null const&, decltype(Null)) = delete; template requires(!not_null::NULL_OP) -[[nodiscard]] cxpr bool operator==(decltype(Null), not_null const&) = delete; +[[nodiscard]] constexpr bool operator==(decltype(Null), not_null const&) = delete; template requires(!not_null::NULL_OP) -[[nodiscard]] cxpr bool operator!=(not_null const&, decltype(Null)) = delete; +[[nodiscard]] constexpr bool operator!=(not_null const&, decltype(Null)) = delete; template requires(!not_null::NULL_OP) -[[nodiscard]] cxpr bool operator!=(decltype(Null), not_null const&) = delete; +[[nodiscard]] constexpr bool operator!=(decltype(Null), not_null const&) = delete; template requires(!not_null::NULL_OP) -[[nodiscard]] cxpr bool operator<(not_null const& left, decltype(Null)) = delete; +[[nodiscard]] constexpr bool operator<(not_null const& left, decltype(Null)) = delete; template requires(!not_null::NULL_OP) -[[nodiscard]] cxpr bool operator<(decltype(Null), not_null const& right) = delete; +[[nodiscard]] constexpr bool operator<(decltype(Null), not_null const& right) = delete; template requires(!not_null::NULL_OP) -[[nodiscard]] cxpr bool operator>(not_null const& left, decltype(Null)) = delete; +[[nodiscard]] constexpr bool operator>(not_null const& left, decltype(Null)) = delete; template requires(!not_null::NULL_OP) -[[nodiscard]] cxpr bool operator>(decltype(Null), not_null const& right) = delete; +[[nodiscard]] constexpr bool operator>(decltype(Null), not_null const& right) = delete; template requires(!not_null::NULL_OP) -[[nodiscard]] cxpr bool operator<=(not_null const& left, decltype(Null)) = delete; +[[nodiscard]] constexpr bool operator<=(not_null const& left, decltype(Null)) = delete; template requires(!not_null::NULL_OP) -[[nodiscard]] cxpr bool operator<=(decltype(Null), not_null const& right) = delete; +[[nodiscard]] constexpr bool operator<=(decltype(Null), not_null const& right) = delete; template requires(!not_null::NULL_OP) -[[nodiscard]] cxpr bool operator>=(not_null const& left, decltype(Null)) = delete; +[[nodiscard]] constexpr bool operator>=(not_null const& left, decltype(Null)) = delete; template requires(!not_null::NULL_OP) -[[nodiscard]] cxpr bool operator>=(decltype(Null), not_null const& right) = delete; +[[nodiscard]] constexpr bool operator>=(decltype(Null), not_null const& right) = delete; } diff --git a/cth/incl/cth/string.hpp b/cth/incl/cth/string.hpp index 84b87cf..b280429 100644 --- a/cth/incl/cth/string.hpp +++ b/cth/incl/cth/string.hpp @@ -21,7 +21,7 @@ concept char_formattable = cth::mta::constructs_any_of to_c_str_vector(std::span const& str_vec) { +[[nodiscard]] constexpr std::vector to_c_str_vector(std::span const& str_vec) { std::vector charVec(str_vec.size()); std::ranges::transform(str_vec, charVec.begin(), [](std::string const& str) { return str.c_str(); }); @@ -30,7 +30,7 @@ namespace cth::str { template -[[nodiscard]] cxpr std::optional to_num(std::string_view str) { +[[nodiscard]] constexpr std::optional to_num(std::string_view str) { T num = 0; size_t i = 0; for(; i < str.size(); i++) { @@ -43,7 +43,7 @@ template if(i == str.size()) return num; - if cxpr(std::is_floating_point_v) { + if constexpr(std::is_floating_point_v) { if(str[i++] != '.') goto failed; @@ -71,10 +71,10 @@ template * @tparam Rng must satisfy rng::static_dim_rng */ template requires(rng::static_dim_rng>) -[[nodiscard]] cxpr std::string to_string(Rng&& range) { - static cxpr bool MD_RANGE = mta::md_range; +[[nodiscard]] constexpr std::string to_string(Rng&& range) { + static constexpr bool MD_RANGE = mta::md_range; - declauto rng = rng::to_viewable(range); + decltype(auto) rng = rng::to_viewable(range); using rng_t = decltype(rng); if(std::ranges::empty(rng)) @@ -108,7 +108,7 @@ template requires(rng::static_dim_rng>) template< mta::convertible_to_any T, mta::convertible_to_any U> -[[nodiscard]] cxpr auto split(T const& str, U const& delimiter) { +[[nodiscard]] constexpr auto split(T const& str, U const& delimiter) { auto const view = mta::to_constructible(str); using char_t = decltype(view)::value_type; using ret_t = std::vector>; @@ -143,7 +143,7 @@ CTH_FORMAT_CPT(cth::str::printable_rng, cth::str::to_string); namespace cth::expr::str { template -[[nodiscard]] cxpr std::optional to_num(std::string_view str, int base) { +[[nodiscard]] constexpr std::optional to_num(std::string_view str, int base) { return cth::str::to_num(str, base); } diff --git a/cth/incl/cth/string/format.hpp b/cth/incl/cth/string/format.hpp index c4dfd4f..703c438 100644 --- a/cth/incl/cth/string/format.hpp +++ b/cth/incl/cth/string/format.hpp @@ -17,7 +17,7 @@ template<> \ struct std::formatter : std::formatter { \ template \ - [[nodiscard]] cxpr auto format(type const& obj, FormatContext& ctx) const { \ + [[nodiscard]] constexpr auto format(type const& obj, FormatContext& ctx) const { \ /* Use the base formatter logic, but pass the member */ \ return std::formatter::format(accessor(obj), ctx); \ } \ @@ -72,11 +72,11 @@ struct std::formatter { #define CTH_FORMAT_CPT(cpt, to_formattable) \ template \ struct std::formatter : std::formatter { \ - [[nodiscard]] cxpr auto parse(std::format_parse_context& ctx) { \ + [[nodiscard]] constexpr auto parse(std::format_parse_context& ctx) { \ return std::formatter::parse(ctx); \ } \ template \ - [[nodiscard]] cxpr auto format(T const& obj, FormatContext& ctx) const { \ + [[nodiscard]] constexpr auto format(T const& obj, FormatContext& ctx) const { \ auto value = to_formattable(obj); \ static_assert( \ !std::same_as, void>, \ diff --git a/cth/incl/cth/test.hpp b/cth/incl/cth/test.hpp index 913dbb4..48f22c3 100644 --- a/cth/incl/cth/test.hpp +++ b/cth/incl/cth/test.hpp @@ -17,7 +17,7 @@ namespace cth::test { template -[[nodiscard]] cxpr bool operator==(LRng&& l_rng, RRng&& r_rng) { +[[nodiscard]] constexpr bool operator==(LRng&& l_rng, RRng&& r_rng) { if constexpr(cth::mta::all_satisfy) if(std::ranges::size(l_rng) != std::ranges::size(r_rng)) return false; @@ -31,7 +31,7 @@ template template -[[nodiscard]] cxpr bool expect_range_eq(L&& l, R&& r) { +[[nodiscard]] constexpr bool expect_range_eq(L&& l, R&& r) { if(std::forward(l) == std::forward(r)) return true; std::println("ranges are not equal!"); diff --git a/cth/tests/src/string_test.cpp b/cth/tests/src/string_test.cpp index 1f3ab7f..f4975c9 100644 --- a/cth/tests/src/string_test.cpp +++ b/cth/tests/src/string_test.cpp @@ -19,7 +19,7 @@ STR_TEST(to_string, range_decline_nonstatic_dim) { } STR_TEST(to_string, value_only_rng) { - static cxpr size_t COUNT = 10; + static constexpr size_t COUNT = 10; std::map map{}; for(size_t i = 0; i < COUNT; i++) @@ -68,7 +68,7 @@ STR_TEST(split, main) { auto res = str::split("asdf asdf asdf dht", " "); - cxpr std::array validRes = {{"asdf", "asdf", "asdf", "dht"}}; + constexpr std::array validRes = {{"asdf", "asdf", "asdf", "dht"}}; for(size_t i = 0; i < res.size(); ++i) EXPECT_EQ(res[i], validRes[i]); diff --git a/cth_win/src/io.cpp b/cth_win/src/io.cpp index 5514046..a0915ff 100644 --- a/cth_win/src/io.cpp +++ b/cth_win/src/io.cpp @@ -10,7 +10,7 @@ namespace cth::win::io { void read_unbuffered(std::string_view path, std::vector& buffer) { - cxpr static size_t PAGE_SIZE = 4096; + constexpr static size_t PAGE_SIZE = 4096; auto const wPath = win::to_wstring(path); diff --git a/cth_win/tests/src/cmd_test.cpp b/cth_win/tests/src/cmd_test.cpp index 7ebfb9a..df287fc 100644 --- a/cth_win/tests/src/cmd_test.cpp +++ b/cth_win/tests/src/cmd_test.cpp @@ -3,7 +3,7 @@ #include "test.hpp" namespace cth::win::cmd { -cxpr std::string_view PATH = "res\\"; +constexpr std::string_view PATH = "res\\"; WIN_TEST(hidden_dir, basic) { diff --git a/cth_win/unused/old_keyboard_api/inl/window.inl b/cth_win/unused/old_keyboard_api/inl/window.inl index a5f9b0b..0a0caad 100644 --- a/cth_win/unused/old_keyboard_api/inl/window.inl +++ b/cth_win/unused/old_keyboard_api/inl/window.inl @@ -39,8 +39,8 @@ inline std::vector screenshot(HWND hwnd, glm::ivec2 size, glm::ivec2 of inline void screenshot_to(std::span buffer, HWND hwnd, glm::ivec2 size, glm::ivec2 offset) { using bmp_swap_ptr = std::unique_ptr, std::function>; - static cxpr int PIXEL_BITS = 24; - static cxpr int PIXEL_BYTES = PIXEL_BITS / 8; + static constexpr int PIXEL_BITS = 24; + static constexpr int PIXEL_BYTES = PIXEL_BITS / 8; CTH_CRITICAL(buffer.size() < static_cast(PIXEL_BYTES * size.x * size.y), "buffer too small") {}