diff --git a/include/stdsharp/array/array.h b/include/stdsharp/array/array.h index 0eadcdd..992cb31 100644 --- a/include/stdsharp/array/array.h +++ b/include/stdsharp/array/array.h @@ -1,6 +1,7 @@ #pragma once #include "../macros.h" +#include "../namespace_alias.h" #include #include diff --git a/include/stdsharp/concepts/object.h b/include/stdsharp/concepts/object.h index 47e292e..c9f6e79 100644 --- a/include/stdsharp/concepts/object.h +++ b/include/stdsharp/concepts/object.h @@ -264,7 +264,8 @@ namespace stdsharp }; template - concept decay_derived = std::is_base_of_v, std::remove_reference_t>; + concept decay_derived = + std::is_base_of_v, std::remove_reference_t>; template concept not_decay_derived = !decay_derived; diff --git a/include/stdsharp/containers/concepts.h b/include/stdsharp/containers/concepts.h index 7d41471..bd5253e 100644 --- a/include/stdsharp/containers/concepts.h +++ b/include/stdsharp/containers/concepts.h @@ -442,13 +442,16 @@ namespace stdsharp::details using size_t = std::size_t; template - static constexpr bool value = std::constructible_from && - [](const std::index_sequence) consteval { - return value...>; - }(std::make_index_sequence{}); + static constexpr bool value = + [](this const auto self, const std::index_sequence) consteval + { + constexpr auto count = sizeof...(I); + auto res = std::constructible_from...>; - template<> - static constexpr bool value<> = std::constructible_from; + if constexpr(count > 0) res = res && self(std::make_index_sequence{}); + + return res; + }(std::make_index_sequence{}); }; } diff --git a/include/stdsharp/default_operator.h b/include/stdsharp/default_operator.h index f4f0df2..104ccf3 100644 --- a/include/stdsharp/default_operator.h +++ b/include/stdsharp/default_operator.h @@ -91,7 +91,8 @@ namespace stdsharp::default_operator struct subscript { #if __cpp_multidimensional_subscript >= 202110L - [[nodiscard]] constexpr decltype(auto) operator[](this auto&& t, auto&& first_arg, auto&&... args) + [[nodiscard]] constexpr decltype(auto + ) operator[](this auto&& t, auto&& first_arg, auto&&... args) noexcept(noexcept(cpp_forward(t)[cpp_forward(first_arg)][cpp_forward(args)...])) requires requires { requires sizeof...(args) > 0; diff --git a/include/stdsharp/exception/exception.h b/include/stdsharp/exception/exception.h index 4e8e9ea..c110424 100644 --- a/include/stdsharp/exception/exception.h +++ b/include/stdsharp/exception/exception.h @@ -1,5 +1,7 @@ #pragma once +#include "../namespace_alias.h" + #include #include #include diff --git a/include/stdsharp/functional/always_return.h b/include/stdsharp/functional/always_return.h index b702baa..feb341b 100644 --- a/include/stdsharp/functional/always_return.h +++ b/include/stdsharp/functional/always_return.h @@ -1,6 +1,7 @@ #pragma once #include "../macros.h" +#include "../namespace_alias.h" #include diff --git a/include/stdsharp/functional/bind_front.h b/include/stdsharp/functional/bind_front.h index 8809214..dbba34a 100644 --- a/include/stdsharp/functional/bind_front.h +++ b/include/stdsharp/functional/bind_front.h @@ -1,6 +1,7 @@ #pragma once #include "../macros.h" +#include "../namespace_alias.h" #include diff --git a/include/stdsharp/functional/empty_invoke.h b/include/stdsharp/functional/empty_invoke.h index 8d31b88..0318d42 100644 --- a/include/stdsharp/functional/empty_invoke.h +++ b/include/stdsharp/functional/empty_invoke.h @@ -1,6 +1,6 @@ #pragma once -#include "stdsharp/type_traits/object.h" +#include "../type_traits/object.h" namespace stdsharp { diff --git a/include/stdsharp/functional/forward_bind.h b/include/stdsharp/functional/forward_bind.h index 4e89278..d9b4d9b 100644 --- a/include/stdsharp/functional/forward_bind.h +++ b/include/stdsharp/functional/forward_bind.h @@ -14,8 +14,7 @@ namespace stdsharp::details } template U = std::remove_cvref_t> - requires std::move_constructible - static constexpr auto forward(T&& t) + static constexpr std::move_constructible auto forward(T&& t) noexcept(nothrow_constructible_from && nothrow_move_constructible) { return U{cpp_forward(t)}; @@ -27,7 +26,8 @@ namespace stdsharp::details template static constexpr decltype(auto) get_forwarded(ForwardT&& t) noexcept { - if constexpr(std::same_as>) return cpp_forward(t); + if constexpr(std::same_as, std::remove_cvref_t>) + return cpp_forward(t); else return cpp_forward(t).get(); } @@ -60,10 +60,10 @@ namespace stdsharp::details template< typename Self, typename Seq = args_t::index_sequence, - auto ForwardCast = forward_cast> - constexpr auto operator()(this Self&& self, auto&&... args) - noexcept(noexcept(ForwardCast(self).invoke(Seq{}, cpp_forward(args)...))) // - -> decltype(ForwardCast(self).invoke(Seq{}, cpp_forward(args)...)) + auto ForwardCast = forward_cast> + constexpr decltype(auto) operator()(this Self&& self, auto&&... args) + noexcept(noexcept(ForwardCast(self).invoke(Seq{}, cpp_forward(args)...))) + requires requires { ForwardCast(self).invoke(Seq{}, cpp_forward(args)...); } { return ForwardCast(self).invoke(Seq{}, cpp_forward(args)...); } diff --git a/include/stdsharp/functional/functional.h b/include/stdsharp/functional/functional.h index 010ea4b..18c73aa 100644 --- a/include/stdsharp/functional/functional.h +++ b/include/stdsharp/functional/functional.h @@ -1,4 +1,5 @@ #pragma once + #include "pipeable.h" #include "stdsharp/functional/always_return.h" #include "stdsharp/functional/bind_front.h" diff --git a/include/stdsharp/functional/invocables.h b/include/stdsharp/functional/invocables.h index 370a2be..9aa2f3e 100644 --- a/include/stdsharp/functional/invocables.h +++ b/include/stdsharp/functional/invocables.h @@ -43,19 +43,19 @@ namespace stdsharp::details template constexpr decltype(auto) get(this Self&& self) noexcept { - return forward_cast>>(self).get(); + return forward_cast>>(self).get(); } template constexpr decltype(auto) cget(this const Self&& self) noexcept { - return forward_cast>>(self).cget(); + return forward_cast>>(self).cget(); } template constexpr forward_cast_t> cget(this const Self& self) noexcept { - return forward_cast>>(self).cget(); + return forward_cast>>(self).cget(); } }; } @@ -101,7 +101,7 @@ namespace std template struct tuple_element> { - using type = ::stdsharp::invocables::template type; + using type = typename ::stdsharp::invocables::template type; }; } diff --git a/include/stdsharp/functional/invoke.h b/include/stdsharp/functional/invoke.h index 6e49bb7..2df5d16 100644 --- a/include/stdsharp/functional/invoke.h +++ b/include/stdsharp/functional/invoke.h @@ -1,7 +1,6 @@ #pragma once -#include "../macros.h" -#include "../namespace_alias.h" +#include "../concepts/object.h" #include @@ -9,11 +8,11 @@ namespace stdsharp { inline constexpr struct invoke_fn { - constexpr auto operator()(auto&&... args) const - noexcept(noexcept(std::invoke(cpp_forward(args)...))) // - -> decltype(std::invoke(cpp_forward(args)...)) + template Fn> + constexpr decltype(auto) operator()(Fn&& fn, Args&&... args) const + noexcept(nothrow_invocable) { - return std::invoke(cpp_forward(args)...); + return std::invoke(cpp_forward(fn), cpp_forward(args)...); } } invoke{}; } \ No newline at end of file diff --git a/include/stdsharp/functional/invoke_r.h b/include/stdsharp/functional/invoke_r.h index 8e3982e..3daa0e2 100644 --- a/include/stdsharp/functional/invoke_r.h +++ b/include/stdsharp/functional/invoke_r.h @@ -1,6 +1,7 @@ #pragma once #include "../macros.h" +#include "../namespace_alias.h" #include #include diff --git a/include/stdsharp/functional/sequenced_invocables.h b/include/stdsharp/functional/sequenced_invocables.h index 588c6fa..3183b46 100644 --- a/include/stdsharp/functional/sequenced_invocables.h +++ b/include/stdsharp/functional/sequenced_invocables.h @@ -92,7 +92,7 @@ namespace std template struct tuple_element> { - using type = ::stdsharp::sequenced_invocables::template type; + using type = typename ::stdsharp::sequenced_invocables::template type; }; } diff --git a/include/stdsharp/iterator/basic_iterator.h b/include/stdsharp/iterator/basic_iterator.h index f844cc2..d3f303d 100644 --- a/include/stdsharp/iterator/basic_iterator.h +++ b/include/stdsharp/iterator/basic_iterator.h @@ -18,7 +18,7 @@ namespace stdsharp using subscript::operator[]; using increase::operator++; using increase::operator--; - using arithmetic::operator+; + using arithmetic::operator-; constexpr auto& operator++(this auto& t) noexcept(noexcept(++t.data())) requires requires { ++t.data(); } @@ -34,20 +34,6 @@ namespace stdsharp return t; } - [[nodiscard]] constexpr auto operator<=>(this const auto& left, const auto& right) - noexcept(noexcept(left.data() <=> right.data())) - requires requires { left.data() <=> right.data(); } - { - return left.data() <=> right.data(); - } - - [[nodiscard]] constexpr auto operator==(this const auto& left, const auto& right) - noexcept(noexcept(left.data() == right.data())) - requires requires { left.data() == right.data(); } - { - return left.data() == right.data(); - } - constexpr auto& operator+=(this auto& t, const difference_type& diff) noexcept requires requires { t.data() += diff; } { @@ -71,6 +57,24 @@ namespace stdsharp return left.data() - right.data(); } + [[nodiscard]] constexpr decltype(auto) operator<=>( // + this const auto& left, + decltype(left) right + ) noexcept(noexcept(left.data() <=> right.data())) + requires requires { left.data() <=> right.data(); } + { + return left.data() <=> right.data(); + } + + [[nodiscard]] constexpr decltype(auto) operator==( // + this const auto& left, + decltype(left) right + ) noexcept(noexcept(left.data() == right.data())) + requires requires { left.data() == right.data(); } + { + return left.data() == right.data(); + } + private: static constexpr void not_null(const nullable_pointer auto& ptr) noexcept { diff --git a/include/stdsharp/memory/allocation.h b/include/stdsharp/memory/allocation.h index 956cd07..e842569 100644 --- a/include/stdsharp/memory/allocation.h +++ b/include/stdsharp/memory/allocation.h @@ -19,8 +19,13 @@ namespace stdsharp::details using allocation_result_base = std::ranges::subrange; + struct basic_allocation_result + { + using allocator_type = Alloc; + }; + // NOLINTBEGIN(*-equals-default) - struct callocation_result : callocation_result_base + struct callocation_result : callocation_result_base, basic_allocation_result { using callocation_result_base::callocation_result_base; @@ -32,7 +37,7 @@ namespace stdsharp::details } }; - struct allocation_result : allocation_result_base + struct allocation_result : allocation_result_base, basic_allocation_result { using allocation_result_base::allocation_result_base; @@ -109,8 +114,9 @@ namespace stdsharp::details }; template - concept allocation_common = requires(const T& t) { - requires nothrow_copyable>; + concept allocation_common = requires(const T& t, std::remove_cvref_t decay_t) { + requires nothrow_copyable; + requires std::same_as; requires std::ranges::sized_range; { std::ranges::size(t) } -> std::same_as>; }; diff --git a/include/stdsharp/memory/allocation_value.h b/include/stdsharp/memory/allocation_value.h index d077a6e..56de817 100644 --- a/include/stdsharp/memory/allocation_value.h +++ b/include/stdsharp/memory/allocation_value.h @@ -9,20 +9,99 @@ namespace stdsharp template struct allocation_value { - using impl_t = allocation_value; // NOLINT(*-c-arrays) + using allocation_traits = allocation_traits; + using allocator_traits = allocation_traits::allocator_traits; + using allocator_type = allocation_traits::allocator_type; + using size_type = allocator_traits::size_type; - public: static constexpr auto always_equal = true; [[nodiscard]] static constexpr auto value_size() noexcept { return sizeof(T); } [[nodiscard]] bool operator==(const allocation_value&) const = default; - template - constexpr void operator()(Args&&... args) const noexcept(nothrow_invocable) - requires std::invocable + private: + using ctor = allocator_traits::constructor; + using dtor = allocator_traits::destructor; + + static constexpr auto data = allocation_traits::template data; + static constexpr auto get = allocation_traits::template get; + + constexpr void size_validate(const auto& allocation) const noexcept { - impl_t{1}(cpp_forward(args)...); + Expects( + allocation.size() * sizeof(typename allocation_traits::value_type) >= value_size() + ); + } + + constexpr void + size_validate(const auto& src_allocation, const auto& dst_allocation) const noexcept + { + size_validate(src_allocation); + size_validate(dst_allocation); + } + + public: + constexpr void operator()( + allocator_type& allocator, + const allocation auto& allocation, + const empty_t /*unused*/ + ) const noexcept(nothrow_invocable) + requires std::invocable + { + size_validate(allocation); + ctor{}(allocator, data(allocation)); + } + + constexpr void operator()( + allocator_type& allocator, + const callocation auto& src_allocation, + const allocation auto& dst_allocation + ) const noexcept(nothrow_invocable) + requires std::invocable + { + size_validate(src_allocation, dst_allocation); + ctor{}(allocator, data(dst_allocation), get(src_allocation)); + } + + constexpr void operator()( + allocator_type& allocator, + const allocation auto& src_allocation, + const allocation auto& dst_allocation + ) const noexcept(nothrow_invocable) + requires std::invocable + { + size_validate(src_allocation, dst_allocation); + ctor{}(allocator, data(dst_allocation), cpp_move(get(src_allocation))); + } + + constexpr void operator()( + const callocation auto& src_allocation, + const allocation auto& dst_allocation + ) const noexcept(nothrow_copy_assignable) + requires copy_assignable + { + size_validate(src_allocation, dst_allocation); + get(dst_allocation) = get(src_allocation); + } + + constexpr void operator()( + const allocation auto& src_allocation, + const allocation auto& dst_allocation + ) const noexcept(nothrow_move_assignable) + requires move_assignable + { + size_validate(src_allocation, dst_allocation); + get(dst_allocation) = cpp_move(get(src_allocation)); + } + + constexpr void operator()( + allocator_type& allocator, + const allocation auto& allocation + ) const noexcept + { + size_validate(allocation); + dtor{}(allocator, data(allocation)); } }; @@ -38,12 +117,11 @@ namespace stdsharp private: using ctor = allocator_traits::constructor; using dtor = allocator_traits::destructor; + using size_t = std::size_t; static constexpr auto data = allocation_traits::template data; - using data_fn = decltype(data); - - std::size_t size_; + size_t size_; constexpr void size_validate(const auto& allocation) const noexcept { @@ -64,11 +142,6 @@ namespace stdsharp return launder_iterator{data(allocation)}; } - [[nodiscard]] constexpr auto launder_rng(const auto& allocation) const noexcept - { - return std::views::iota(launder_begin(allocation)) | std::views::take(size()); - } - [[nodiscard]] constexpr auto value_rng(const auto& allocation) const noexcept { return std::views::counted(launder_begin(allocation), size()); @@ -92,7 +165,9 @@ namespace stdsharp { size_validate(allocation); - for(const auto iter : launder_rng(allocation)) ctor{}(allocator, iter.data()); + auto p = data(allocation); + const auto count = size(); + for(size_t i = 0; i < count; ++i, ++p) ctor{}(allocator, p); } constexpr void operator()( @@ -104,9 +179,12 @@ namespace stdsharp { size_validate(src_allocation, dst_allocation); - for(auto dst_begin = launder_iterator{data(dst_allocation)}; - const auto& value : value_rng(src_allocation)) - ctor{}(allocator, dst_begin++.data(), value); + auto dst_begin = data(dst_allocation); + const auto& src_begin = launder_begin(src_allocation); + const auto count = size(); + + for(size_t i = 0; i < count; ++i, ++dst_begin) + ctor{}(allocator, dst_begin, src_begin[i]); } constexpr void operator()( @@ -118,9 +196,12 @@ namespace stdsharp { size_validate(src_allocation, dst_allocation); - for(auto dst_begin = launder_iterator{data(dst_allocation)}; - auto& value : value_rng(src_allocation)) - ctor{}(allocator, dst_begin++.data(), cpp_move(value)); + auto dst_begin = data(dst_allocation); + const auto& src_begin = launder_begin(src_allocation); + const auto count = size(); + + for(size_t i = 0; i < count; ++i, ++dst_begin) + ctor{}(allocator, dst_begin, cpp_move(src_begin[i])); } constexpr void operator()( @@ -130,11 +211,10 @@ namespace stdsharp requires copy_assignable { size_validate(src_allocation, dst_allocation); - - std::ranges::copy_n( - launder_iterator{data(src_allocation)}, + std::ranges::copy_n( // + launder_begin(src_allocation), size(), - launder_iterator{data(dst_allocation)} + launder_begin(dst_allocation) ); } @@ -145,12 +225,7 @@ namespace stdsharp requires move_assignable { size_validate(src_allocation, dst_allocation); - - move_n( - launder_iterator{data(src_allocation)}, - size(), - launder_iterator{data(dst_allocation)} - ); + move_n(launder_begin(src_allocation), size(), launder_begin(dst_allocation)); } constexpr void operator()( @@ -160,7 +235,9 @@ namespace stdsharp { size_validate(allocation); - for(const auto iter : launder_rng(allocation)) dtor{}(allocator, iter.data()); + auto iter = launder_begin(allocation); + const auto count = size(); + for(size_t i = 0; i < count; ++i, ++iter) dtor{}(allocator, iter.data()); } }; } \ No newline at end of file diff --git a/include/stdsharp/memory/box.h b/include/stdsharp/memory/box.h index 3c93d65..f6a35cd 100644 --- a/include/stdsharp/memory/box.h +++ b/include/stdsharp/memory/box.h @@ -68,18 +68,13 @@ namespace stdsharp using m_dispatchers = details::box_traits::dispatchers; indexed_values values_{}; + std::reference_wrapper type_ = type_info; constexpr decltype(auto) dispatchers(this auto&& self) noexcept { return cpp_forward(self).values_.template get<0>(); } - template - [[nodiscard]] constexpr bool equal_to(const allocation_value& other) const noexcept - { - return dispatchers().template get() == other.dispatchers().template get(); - } - public: allocation_value() = default; @@ -91,19 +86,18 @@ namespace stdsharp ForwardCast(self).dispatchers()(cpp_forward(args)...); } + [[nodiscard]] auto& type() const noexcept { return type_.get(); } + constexpr bool operator==(const allocation_value& other) const noexcept { - return equal_to<0>(other) && // - equal_to<1>(other) && // - equal_to<2>(other) && // - equal_to<3>(other) && // - equal_to<4>(other); + return type_.get() == other.type_.get(); } template> requires details::box_type_compatible explicit constexpr allocation_value(const std::in_place_type_t /*unused*/) noexcept: - values_(m_dispatchers{Op{}, Op{}, Op{}, Op{}, Op{}}, std::size_t{sizeof(T)}) + values_(m_dispatchers{Op{}, Op{}, Op{}, Op{}, Op{}}, std::size_t{sizeof(T)}), + type_(type_info) { } @@ -112,7 +106,8 @@ namespace stdsharp explicit constexpr allocation_value( const allocation_value> other ) noexcept: - values_(m_dispatchers{other, other, other, other, other}, {other.value_size_()}) + values_(m_dispatchers{other, other, other, other, other}, {other.value_size_()}), + type_(other.type_) { } @@ -562,7 +557,7 @@ namespace stdsharp [[nodiscard]] constexpr auto is_type() const noexcept { if constexpr(std::constructible_from>) - return allocation_value_ == allocation_value{std::in_place_type_t{}}; + return allocation_value_.type() == type_info; else return false; } diff --git a/include/stdsharp/memory/composed_allocator.h b/include/stdsharp/memory/composed_allocator.h index 168aed9..f5ddf47 100644 --- a/include/stdsharp/memory/composed_allocator.h +++ b/include/stdsharp/memory/composed_allocator.h @@ -23,14 +23,15 @@ namespace stdsharp to_pointer(ptr) } noexcept; } - class composed_allocator + class composed_allocator : indexed_values { public: using first_allocator_type = FirstAlloc; using second_allocator_type = SecondAlloc; + using value_type = FirstAlloc::value_type; private: - std::pair alloc_pair_; + using indexed_values = indexed_values; using first_traits = allocator_traits; using second_traits = allocator_traits; @@ -47,9 +48,9 @@ namespace stdsharp using first_cvp_traits = pointer_traits; using second_cvp_traits = pointer_traits; - public: - using value_type = FirstAlloc::value_type; + static constexpr auto pointer_cast = stdsharp::pointer_cast; + public: using propagate_on_container_copy_assignment = std::disjunction< typename first_traits::propagate_on_container_copy_assignment, typename second_traits::propagate_on_container_copy_assignment>; @@ -74,20 +75,21 @@ namespace stdsharp composed_allocator() = default; - template Pair = decltype(alloc_pair_)> + template + requires std::constructible_from constexpr explicit(sizeof...(Args) == 1) composed_allocator(Args&&... args) - noexcept(nothrow_constructible_from): - alloc_pair_(cpp_forward(args)...) + noexcept(nothrow_constructible_from): + indexed_values(cpp_forward(args)...) { } [[nodiscard]] constexpr auto allocate(const std::size_t n, const void* const hint = nullptr) { const auto ptr = first_traits:: - try_allocate(alloc_pair_.first, n, first_cvp_traits::to_pointer(hint)); + try_allocate(get_first_allocator(), n, first_cvp_traits::to_pointer(hint)); return ptr == nullptr ? // second_traits:: - allocate(alloc_pair_.second, n, second_cvp_traits::to_pointer(hint)) : + allocate(get_second_allocator(), n, second_cvp_traits::to_pointer(hint)) : ptr; } @@ -95,34 +97,35 @@ namespace stdsharp try_allocate(const std::size_t n, const void* const hint = nullptr) noexcept { const auto ptr = first_traits:: - try_allocate(alloc_pair_.first, n, first_cvp_traits::to_pointer(hint)); + try_allocate(get_first_allocator(), n, first_cvp_traits::to_pointer(hint)); return ptr == nullptr ? // second_traits:: - try_allocate(alloc_pair_.second, n, second_cvp_traits::to_pointer(hint)) : + try_allocate(get_second_allocator(), n, second_cvp_traits::to_pointer(hint)) : ptr; } constexpr void deallocate(value_type* const ptr, const std::size_t n) noexcept { - auto& [first, second] = alloc_pair_; + auto& first = get_first_allocator(); if(auto first_ptr_v = pointer_traits::to_pointer(ptr); first.contains(first_ptr_v)) first.deallocate(ptr, n); - else second.deallocate(pointer_traits::to_pointer(ptr), n); + else get_second_allocator().deallocate(pointer_traits::to_pointer(ptr), n); } [[nodiscard]] constexpr auto max_size() const noexcept { - return std:: - min(first_traits::max_size(alloc_pair_.first), - second_traits::max_size(alloc_pair_.second)); + return std::min( // + first_traits::max_size(get_first_allocator()), + second_traits::max_size(get_second_allocator()) + ); } [[nodiscard]] constexpr composed_allocator select_on_container_copy_construction() const { return { - first_traits::select_on_container_copy_construction(alloc_pair_.first), - second_traits::select_on_container_copy_construction(alloc_pair_.second) + first_traits::select_on_container_copy_construction(get_first_allocator()), + second_traits::select_on_container_copy_construction(get_second_allocator()) }; } @@ -137,13 +140,13 @@ namespace stdsharp aggregate_try( [&result, this, n] { - const auto& res = first_traits::allocate_at_least(alloc_pair_.first, n); + const auto& res = first_traits::allocate_at_least(get_first_allocator(), n); result = {.ptr = first_ptr_traits::to_address(res.ptr), .count = res.count}; }, [&result, this, n] { - const auto& res = second_traits::allocate_at_least(alloc_pair_.second, n); + const auto& res = second_traits::allocate_at_least(get_second_allocator(), n); result = {.ptr = second_ptr_traits::to_address(res.ptr), .count = res.count}; } @@ -164,40 +167,41 @@ namespace stdsharp nothrow_invocable // ) { - auto& [first, second] = alloc_pair_; - if(first.contains(pointer_traits::to_pointer(ptr))) + if(auto& first = get_first_allocator(); + first.contains(pointer_traits::to_pointer(pointer_cast(ptr)))) return first_traits::construct(first, ptr, cpp_forward(args)...); - return second_traits::construct(second, ptr, cpp_forward(args)...); + return second_traits::construct(get_second_allocator(), ptr, cpp_forward(args)...); } [[nodiscard]] constexpr bool contains(const value_type* const ptr) const noexcept requires allocator_contains { const auto vp = static_cast(ptr); - const auto& [first, second] = alloc_pair_; - return first.contains(pointer_traits::to_pointer(vp)) || - second.contains(pointer_traits::to_pointer(vp)); + return get_first_allocator().contains(pointer_traits::to_pointer(vp)) || + get_second_allocator().contains(pointer_traits::to_pointer(vp)); } [[nodiscard]] bool operator==(const composed_allocator&) const noexcept = default; - [[nodiscard]] constexpr auto& get_allocators() const noexcept { return alloc_pair_; } - - [[nodiscard]] constexpr auto& get_allocators() noexcept { return alloc_pair_; } - [[nodiscard]] constexpr auto& get_first_allocator() const noexcept { - return alloc_pair_.first; + return indexed_values::template get<0>(); } - [[nodiscard]] constexpr auto& get_first_allocator() noexcept { return alloc_pair_.first; } + [[nodiscard]] constexpr auto& get_first_allocator() noexcept + { + return indexed_values::template get<0>(); + } [[nodiscard]] constexpr auto& get_second_allocator() const noexcept { - return alloc_pair_.second; + return indexed_values::template get<1>(); } - [[nodiscard]] constexpr auto& get_second_allocator() noexcept { return alloc_pair_.second; } + [[nodiscard]] constexpr auto& get_second_allocator() noexcept + { + return indexed_values::template get<1>(); + } }; template diff --git a/include/stdsharp/memory/launder_iterator.h b/include/stdsharp/memory/launder_iterator.h index f40c2b0..ffc663f 100644 --- a/include/stdsharp/memory/launder_iterator.h +++ b/include/stdsharp/memory/launder_iterator.h @@ -8,12 +8,10 @@ namespace stdsharp { template // NOLINTBEGIN(*-pointer-arithmetic) - class launder_iterator : public basic_iterator, public std::random_access_iterator_tag + class launder_iterator : public basic_iterator { T* ptr_; - constexpr void not_null() const noexcept { assert_not_null(ptr_); } - [[nodiscard]] constexpr auto& data() noexcept { return ptr_; } friend basic_iterator; @@ -22,26 +20,19 @@ namespace stdsharp using value_type = T; using difference_type = std::ptrdiff_t; - launder_iterator() = default; - - constexpr launder_iterator(T* const ptr) noexcept: ptr_(ptr) { not_null(); } + constexpr launder_iterator(T* const ptr) noexcept: ptr_(ptr) {} - launder_iterator(nullptr_t) = delete; + launder_iterator() = default; - launder_iterator(launder_iterator&&) noexcept = default; - launder_iterator& operator=(const launder_iterator&) noexcept = default; - launder_iterator& operator=(launder_iterator&&) noexcept = default; - launder_iterator(const launder_iterator&) noexcept = default; - ~launder_iterator() noexcept = default; + [[nodiscard]] constexpr auto data() const noexcept { return std::launder(ptr_); } [[nodiscard]] constexpr decltype(auto) operator[](const difference_type diff) const noexcept { - not_null(); + assert_not_null(ptr_); return *std::launder(ptr_ + diff); } - using default_operator::subscript::operator[]; - using default_operator::arithmetic::operator-; + using basic_iterator::operator[]; }; // NOLINTEND(*-pointer-arithmetic) template diff --git a/include/stdsharp/memory/pointer_traits.h b/include/stdsharp/memory/pointer_traits.h index 458c693..3e2e14a 100644 --- a/include/stdsharp/memory/pointer_traits.h +++ b/include/stdsharp/memory/pointer_traits.h @@ -37,7 +37,7 @@ namespace stdsharp::details } public: - using pointer = decltype(get_pointer_type())::type; + using pointer = typename decltype(get_pointer_type())::type; template struct element_type_t diff --git a/include/stdsharp/memory/single_stack_allocator.h b/include/stdsharp/memory/single_stack_allocator.h index 5f41a34..66bbc2e 100644 --- a/include/stdsharp/memory/single_stack_allocator.h +++ b/include/stdsharp/memory/single_stack_allocator.h @@ -55,7 +55,7 @@ namespace stdsharp return resource() == other.resource(); } - [[nodiscard]] constexpr bool contains(const void* const ptr) const noexcept + [[nodiscard]] constexpr bool contains(const T* const ptr) const noexcept { return resource().contains(ptr); } diff --git a/include/stdsharp/tuple/get.h b/include/stdsharp/tuple/get.h index 02c5e09..d3e7e65 100644 --- a/include/stdsharp/tuple/get.h +++ b/include/stdsharp/tuple/get.h @@ -1,6 +1,6 @@ #pragma once -#include "stdsharp/concepts/object.h" +#include "../concepts/object.h" namespace stdsharp::cpo::inline cpo_impl { diff --git a/include/stdsharp/type_traits/indexed_traits.h b/include/stdsharp/type_traits/indexed_traits.h index 0693898..8baa23d 100644 --- a/include/stdsharp/type_traits/indexed_traits.h +++ b/include/stdsharp/type_traits/indexed_traits.h @@ -35,7 +35,7 @@ namespace stdsharp::details } template - using type = decltype( // + using type = typename decltype( // impl(std::index_sequence_for{}, basic_type_sequence{}).get() )::type; }; @@ -127,7 +127,7 @@ namespace std template struct tuple_element> { - using type = ::stdsharp::indexed_values::template type; + using type = typename ::stdsharp::indexed_values::template type; }; } diff --git a/include/stdsharp/type_traits/ltr.h b/include/stdsharp/type_traits/ltr.h index eda3e7a..cc2adeb 100644 --- a/include/stdsharp/type_traits/ltr.h +++ b/include/stdsharp/type_traits/ltr.h @@ -1,5 +1,7 @@ #pragma once +#include "../namespace_alias.h" + #include #include #include diff --git a/include/stdsharp/type_traits/type.h b/include/stdsharp/type_traits/type.h index 33c8dc0..0242810 100644 --- a/include/stdsharp/type_traits/type.h +++ b/include/stdsharp/type_traits/type.h @@ -150,7 +150,7 @@ namespace stdsharp ttp_expend(T...) -> ttp_expend; template typename T, typename Seq> - using make_ttp_expend_by = decltype( // + using make_ttp_expend_by = typename decltype( // [] typename Inner, typename... U>(const Inner&) { return std::type_identity>{}; // @@ -268,17 +268,17 @@ namespace stdsharp static constexpr auto ptr = Ptr; constexpr auto operator()(auto&&... args) const - noexcept(noexcept(invoke(ptr, cpp_forward(args)...)) - ) -> decltype(invoke(ptr, cpp_forward(args)...)) + noexcept(noexcept(invoke(ptr, cpp_forward(args)...))) // + -> decltype(invoke(ptr, cpp_forward(args)...)) { return invoke(ptr, cpp_forward(args)...); } }; -#define STDSHARP_MEMBER_FUNCTION_TRAITS(const_, volatile_, ref_, qualifiers) \ - template \ - struct member_traits : \ - function_traits \ +#define STDSHARP_MEMBER_FUNCTION_TRAITS(const_, volatile_, ref_, noexcept_, qualifiers) \ + template \ + struct member_traits : \ + function_traits \ { \ static constexpr auto is_const = const_; \ static constexpr auto is_volatile = volatile_; \ @@ -288,9 +288,13 @@ namespace stdsharp using qualified_class_t = apply_qualifiers; \ }; -#define STDSHARP_MEMBER_FUNCTION_TRAITS_CONST_PACK(is_volatile, ref_type, qualifiers) \ - STDSHARP_MEMBER_FUNCTION_TRAITS(true, is_volatile, ref_type, const qualifiers) \ - STDSHARP_MEMBER_FUNCTION_TRAITS(false, is_volatile, ref_type, qualifiers) +#define STDSHARP_MEMBER_FUNCTION_TRAITS_NOEXCEPT_PACK(const_, is_volatile, ref_type, qualifiers) \ + STDSHARP_MEMBER_FUNCTION_TRAITS(const_, is_volatile, ref_type, true, qualifiers noexcept) \ + STDSHARP_MEMBER_FUNCTION_TRAITS(const_, is_volatile, ref_type, false, qualifiers) + +#define STDSHARP_MEMBER_FUNCTION_TRAITS_CONST_PACK(is_volatile, ref_type, qualifiers) \ + STDSHARP_MEMBER_FUNCTION_TRAITS_NOEXCEPT_PACK(true, is_volatile, ref_type, const qualifiers) \ + STDSHARP_MEMBER_FUNCTION_TRAITS_NOEXCEPT_PACK(false, is_volatile, ref_type, qualifiers) #define STDSHARP_MEMBER_FUNCTION_TRAITS_VOLATILE_PACK(ref_type, qualifiers) \ STDSHARP_MEMBER_FUNCTION_TRAITS_CONST_PACK(true, ref_type, volatile qualifiers) \ diff --git a/include/stdsharp/utility/cast_to.h b/include/stdsharp/utility/cast_to.h index 9c9fe74..408765f 100644 --- a/include/stdsharp/utility/cast_to.h +++ b/include/stdsharp/utility/cast_to.h @@ -1,6 +1,6 @@ #pragma once -#include "../concepts/concepts.h" +#include "../concepts/object.h" #include "../compilation_config_in.h" diff --git a/include/stdsharp/utility/dispatcher.h b/include/stdsharp/utility/dispatcher.h index 1796b71..3d095c6 100644 --- a/include/stdsharp/utility/dispatcher.h +++ b/include/stdsharp/utility/dispatcher.h @@ -33,9 +33,10 @@ namespace stdsharp::details else return +[](Args... args) noexcept(no_exception) -> Ret { - constexpr Fn c{}; // NOLINTBEGIN(*-redundant-casting) - if constexpr(std::same_as) c(static_cast(args)...); - else return c(static_cast(args)...); // NOLINTEND(*-redundant-casting) + return invoke_r( + Fn{}, + static_cast(args)... // NOLINT(*-redundant-casting) + ); }; } diff --git a/include/stdsharp/utility/forward_cast.h b/include/stdsharp/utility/forward_cast.h index 81a3c21..59c6046 100644 --- a/include/stdsharp/utility/forward_cast.h +++ b/include/stdsharp/utility/forward_cast.h @@ -8,78 +8,55 @@ namespace stdsharp { + + template + using forward_cast_t = apply_qualifiers< + To, + const_>, + volatile_>, + ref_qualifier_v>; + template struct forward_cast_fn { private: - template - friend class forward_cast_fn; - using current_fn = forward_cast_fn; - - template - using combined_fn = typename forward_cast_fn:: - template combined_fn; - - using no_ref_from_t = std::remove_reference_t; + using current_cast_t = typename current_fn::cast_t; + using next_fn = forward_cast_fn; public: - [[nodiscard]] constexpr auto operator()(auto&& from) const noexcept -> // - decltype(combined_fn<>{}(static_cast(from))) + [[nodiscard]] constexpr decltype(auto) operator()(auto&& from) const noexcept + requires std::invocable && std::invocable { - return combined_fn<>{}(static_cast(from)); + return next_fn{}(current_fn{}(static_cast(from))); } }; template - using forward_cast_t = forward_cast_fn::cast_t; + requires requires(std::remove_cvref_t f, std::remove_cvref_t t) { + requires not_same_as; + requires !(base_of || base_of); + } + struct forward_cast_fn + { + }; template struct forward_cast_fn { - private: - template - friend class forward_cast_fn; - - template - struct combined_fn - { - constexpr auto operator()(auto&& from) const noexcept - -> decltype((cpp_forward(from) | ... | Fn{}) | forward_cast_fn{}) - { - return (cpp_forward(from) | ... | Fn{}) | forward_cast_fn{}; - } - }; - - using no_ref_from_t = std::remove_reference_t; - - public: - using from_t = std::remove_cv_t; - using to_t = std::remove_cvref_t; - using cast_t = apply_qualifiers< - To, - const_, - volatile_, - ref_qualifier_v>; + using cast_t = forward_cast_t; - template - requires(base_of || base_of) && - std::same_as, no_ref_from_t> - [[nodiscard]] constexpr decltype(auto) operator()(T&& from) const noexcept + // c-style cast allow us cast to inaccessible base + [[nodiscard]] constexpr decltype(auto) operator()(std::remove_reference_t&& from) // + const noexcept { - // c-style cast allow us cast to inaccessible base - if constexpr(not_same_as) return (cast_t)from; // NOLINT - else return static_cast(from); + return (cast_t)from; // NOLINT } - template - requires std::invocable - [[nodiscard]] friend constexpr decltype(auto) operator|( - T&& from, - const forward_cast_fn& self // - ) noexcept + [[nodiscard]] constexpr decltype(auto) operator()(std::remove_reference_t& from) // + const noexcept { - return self(cpp_forward(from)); + return (cast_t)from; // NOLINT } }; diff --git a/include/stdsharp/utility/to_lvalue.h b/include/stdsharp/utility/to_lvalue.h index 80bbfc0..a6be6dd 100644 --- a/include/stdsharp/utility/to_lvalue.h +++ b/include/stdsharp/utility/to_lvalue.h @@ -1,6 +1,6 @@ #pragma once -#include "../concepts/concepts.h" +#include "../concepts/object.h" #include "../compilation_config_in.h" diff --git a/include/stdsharp/utility/value_wrapper.h b/include/stdsharp/utility/value_wrapper.h index adf03ba..9a7c78a 100644 --- a/include/stdsharp/utility/value_wrapper.h +++ b/include/stdsharp/utility/value_wrapper.h @@ -10,13 +10,11 @@ namespace stdsharp::details template class value_wrapper { - T v{}; + T v; public: - value_wrapper() = default; - template - requires(sizeof...(U) > 0) && std::constructible_from + requires std::constructible_from constexpr value_wrapper(U&&... u) noexcept(nothrow_constructible_from): v(cpp_forward(u)...) { diff --git a/tests/.clang-tidy b/tests/.clang-tidy index b7ba13a..c1b5991 100644 --- a/tests/.clang-tidy +++ b/tests/.clang-tidy @@ -1,3 +1,3 @@ --- -InheritParentConfig: true +InheritParentConfig: false Checks: '-*-magic-numbers,-*-chained-comparison,-*-move-const-arg,-*-const-correctness' \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8a07489..a347286 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -15,28 +15,29 @@ set(src src/algorithm/algorithm.cpp src/containers/actions.cpp src/containers/concepts.cpp - src/filesystem/filesystem.cpp - src/functional/forward_bind.cpp + # src/filesystem/filesystem.cpp + # src/functional/forward_bind.cpp src/functional/invocables.cpp - src/functional/pipeable.cpp + # src/functional/pipeable.cpp src/functional/sequenced_invocables.cpp - src/functional/symmetric_operations.cpp - src/memory/box.cpp - src/memory/composed_allocator.cpp - src/memory/pointer_traits.cpp - src/memory/single_stack_allocator.cpp - src/memory/soo.cpp - src/type_traits/indexed_traits.cpp - src/type_traits/member.cpp - src/type_traits/type_sequence.cpp - src/type_traits/value_sequence.cpp + # src/functional/symmetric_operations.cpp + # src/memory/box.cpp + # src/memory/composed_allocator.cpp + # src/memory/pointer_traits.cpp + # src/memory/single_stack_allocator.cpp + # src/memory/soo.cpp + # src/type_traits/indexed_traits.cpp + # src/type_traits/member.cpp + # src/type_traits/type_sequence.cpp + # src/type_traits/value_sequence.cpp src/utility/forward_cast.cpp - src/utility/dispatcher.cpp - src/utility/utility.cpp - src/utility/value_wrapper.cpp - src/lazy.cpp - src/pattern_match.cpp - src/synchronizer.cpp) + # src/utility/dispatcher.cpp + # src/utility/utility.cpp + # src/utility/value_wrapper.cpp + # src/lazy.cpp + # src/pattern_match.cpp + # src/synchronizer.cpp + ) config_lib(${PROJECT_NAME}Lib INTERFACE) @@ -48,8 +49,7 @@ config_exe(${PROJECT_NAME} EXE_SRC ${src}) target_compile_options( ${PROJECT_NAME} PUBLIC $<$:/W4 /wd4459> - $<$:-Qunused-arguments -ftime-trace - -fdiagnostics-show-template-tree -ftemplate-backtrace-limit=0>) + $<$:-Qunused-arguments -ftime-trace -ftemplate-backtrace-limit=0>) target_enable_clang_sanitizer(${PROJECT_NAME} PUBLIC SANITIZER address undefined) target_link_libraries(${PROJECT_NAME} PRIVATE ${PROJECT_NAME}Lib) @@ -61,7 +61,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_WARNING_AS_ERROR ON) # option(ENABLE_CLANG_TIDY "Enable clang-tidy" OFF) -if(${ENABLE_CLANG_TIDY}) +if(${ENABLE_CLANG_TIDY} AND (${CMAKE_CXX_COMPILER_ID} MATCHES "(Apple)?[Cc]lang")) message(STATUS "clang-tidy is enabled") target_enable_clang_tidy(${PROJECT_NAME}) diff --git a/tests/src/functional/invocables.cpp b/tests/src/functional/invocables.cpp index 2f326c2..243d96b 100644 --- a/tests/src/functional/invocables.cpp +++ b/tests/src/functional/invocables.cpp @@ -25,12 +25,16 @@ SCENARIO("invocables", "[function][invocables]") // NOLINT using invocables = invocables; - STATIC_REQUIRE(std::constructible_from); - STATIC_REQUIRE(std::constructible_from); - STATIC_REQUIRE(std::constructible_from); - STATIC_REQUIRE(std::constructible_from); - STATIC_REQUIRE(std::constructible_from); - STATIC_REQUIRE(!std::invocable); - REQUIRE(invocables{}(static_cast(nullptr)) == 2); - REQUIRE(invocables{}(static_cast(nullptr)) == 3); + invocables fn{}; + + REQUIRE(fn.get<0>()(1) == 0); + REQUIRE(fn.cget<0>()(1) == 0); + STATIC_REQUIRE(constructible_from); + STATIC_REQUIRE(constructible_from); + STATIC_REQUIRE(constructible_from); + STATIC_REQUIRE(constructible_from); + STATIC_REQUIRE(constructible_from); + STATIC_REQUIRE(!invocable); + REQUIRE(fn(static_cast(nullptr)) == 2); + REQUIRE(fn(static_cast(nullptr)) == 3); } \ No newline at end of file diff --git a/tests/src/functional/pipeable.cpp b/tests/src/functional/pipeable.cpp index 0c001e7..c319508 100644 --- a/tests/src/functional/pipeable.cpp +++ b/tests/src/functional/pipeable.cpp @@ -4,7 +4,7 @@ SCENARIO("pipeable, [functional][pipeable]") // NOLINT { { - constexpr auto fn = make_pipeable(std::identity{}); + constexpr auto fn = make_pipeable(identity{}); fn(1); @@ -12,7 +12,7 @@ SCENARIO("pipeable, [functional][pipeable]") // NOLINT } { - constexpr auto fn = make_pipeable(std::identity{}); + constexpr auto fn = make_pipeable(identity{}); STATIC_REQUIRE((fn | 1) == 1); } diff --git a/tests/src/functional/sequenced_invocables.cpp b/tests/src/functional/sequenced_invocables.cpp index 4cc42c7..71758f2 100644 --- a/tests/src/functional/sequenced_invocables.cpp +++ b/tests/src/functional/sequenced_invocables.cpp @@ -12,10 +12,10 @@ SCENARIO("sequenced invocables", "[functional][sequenced invocables]") REQUIRE(fn(1) == 1); STATIC_REQUIRE(fn.size() == 2); - STATIC_REQUIRE(std::invocable); - STATIC_REQUIRE(std::invocable); - STATIC_REQUIRE(std::invocable>); - STATIC_REQUIRE(std::invocable>); - STATIC_REQUIRE(!std::invocable); - STATIC_REQUIRE(!std::invocable); + STATIC_REQUIRE(invocable); + STATIC_REQUIRE(invocable); + STATIC_REQUIRE(invocable>); + STATIC_REQUIRE(invocable>); + STATIC_REQUIRE(!invocable); + STATIC_REQUIRE(!invocable); } \ No newline at end of file diff --git a/tests/src/lazy.cpp b/tests/src/lazy.cpp index f072dbd..515d244 100644 --- a/tests/src/lazy.cpp +++ b/tests/src/lazy.cpp @@ -5,7 +5,7 @@ SCENARIO("lazy", "[lazy]") // NOLINT { GIVEN("a lazy value") { - stdsharp::lazy lazy{[]() { return std::string{"foo"}; }}; + stdsharp::lazy lazy{[]() { return string{"foo"}; }}; WHEN("get value") { diff --git a/tests/src/memory/box.cpp b/tests/src/memory/box.cpp index 31726d6..0c44a0e 100644 --- a/tests/src/memory/box.cpp +++ b/tests/src/memory/box.cpp @@ -3,7 +3,7 @@ using allocator_t = allocator; -SCENARIO("box basic requirements", "[memory]") // NOLINT +SCENARIO("box basic requirements", "[memory][box]") // NOLINT { using normal_t = normal_box; using unique_t = unique_box; @@ -18,20 +18,12 @@ SCENARIO("box basic requirements", "[memory]") // NOLINT allocation_type_requirement_test(); } -SCENARIO("box assign value", "[memory]") // NOLINT +SCENARIO("box assign value", "[memory][box]") // NOLINT { allocation_functionality_test>(); } -void foo() -{ - int v0{}; - launder_iterator v1{&v0}; - launder_iterator v2{&v0}; - auto v3 = v1 == v2; -} - -SCENARIO("constexpr box", "[memory]") // NOLINT +SCENARIO("constexpr box", "[memory][box]") // NOLINT { STATIC_REQUIRE( [] diff --git a/tests/src/memory/composed_allocator.cpp b/tests/src/memory/composed_allocator.cpp index 884d4fe..b33fbca 100644 --- a/tests/src/memory/composed_allocator.cpp +++ b/tests/src/memory/composed_allocator.cpp @@ -37,7 +37,7 @@ SCENARIO("allocate memory", "[memory][composed_allocator]") // NOLINT THEN("write values") { - constexpr auto data = std::views::iota(0, count); + constexpr auto data = views::iota(0, count); std::ranges::copy(data, ptr); REQUIRE_THAT(data, Catch::Matchers::RangeEquals(span(ptr, count))); } diff --git a/tests/src/memory/pointer_traits.cpp b/tests/src/memory/pointer_traits.cpp index a73e5a4..e8bac83 100644 --- a/tests/src/memory/pointer_traits.cpp +++ b/tests/src/memory/pointer_traits.cpp @@ -13,9 +13,9 @@ SCENARIO("pointer traits", "[memory]") // NOLINT using traits = stdsharp::pointer_traits; - STATIC_REQUIRE(std::same_as); - STATIC_REQUIRE(std::same_as); - STATIC_REQUIRE(std::same_as); + STATIC_REQUIRE(same_as); + STATIC_REQUIRE(same_as); + STATIC_REQUIRE(same_as); STATIC_REQUIRE( // !requires { requires( // @@ -41,10 +41,10 @@ SCENARIO("pointer traits", "[memory]") // NOLINT static_assert(dereferenceable); - STATIC_REQUIRE(std::same_as); - STATIC_REQUIRE(std::same_as); - STATIC_REQUIRE(std::same_as); - STATIC_REQUIRE(std::same_as); + STATIC_REQUIRE(same_as); + STATIC_REQUIRE(same_as); + STATIC_REQUIRE(same_as); + STATIC_REQUIRE(same_as); } GIVEN("a int fancy pointer") @@ -58,10 +58,10 @@ SCENARIO("pointer traits", "[memory]") // NOLINT using traits = stdsharp::pointer_traits; - STATIC_REQUIRE(std::same_as); - STATIC_REQUIRE(std::same_as); - STATIC_REQUIRE(std::same_as); - STATIC_REQUIRE(std::same_as); + STATIC_REQUIRE(same_as); + STATIC_REQUIRE(same_as); + STATIC_REQUIRE(same_as); + STATIC_REQUIRE(same_as); int value = 42; int* ptr = &value; @@ -77,10 +77,10 @@ SCENARIO("pointer traits", "[memory]") // NOLINT { using traits = stdsharp::pointer_traits; - STATIC_REQUIRE(std::same_as); - STATIC_REQUIRE(std::same_as); - STATIC_REQUIRE(std::same_as); - STATIC_REQUIRE(std::same_as); + STATIC_REQUIRE(same_as); + STATIC_REQUIRE(same_as); + STATIC_REQUIRE(same_as); + STATIC_REQUIRE(same_as); int value = 42; int* ptr = &value; diff --git a/tests/src/memory/single_stack_allocator.cpp b/tests/src/memory/single_stack_allocator.cpp index f571c3d..32f59da 100644 --- a/tests/src/memory/single_stack_allocator.cpp +++ b/tests/src/memory/single_stack_allocator.cpp @@ -36,7 +36,7 @@ SCENARIO("single stack allocator", "[memory][single_stack_allocator]") // NOLINT const base* const ptr = p1; constexpr int v = 42; - std::ranges::construct_at(p1, v); + construct_at(p1, v); REQUIRE(ptr->foo() == v); @@ -50,7 +50,7 @@ SCENARIO("single stack allocator", "[memory][single_stack_allocator]") // NOLINT const derived* const ptr = p1; constexpr int v = 42; - std::ranges::construct_at(p1, v); + construct_at(p1, v); REQUIRE(ptr->foo() == v); diff --git a/tests/src/memory/soo.cpp b/tests/src/memory/soo.cpp index 6369e64..821f1b0 100644 --- a/tests/src/memory/soo.cpp +++ b/tests/src/memory/soo.cpp @@ -7,10 +7,10 @@ SCENARIO("soo allocation basic requirements", "[memory][small object optimizatio using unique_t = unique_soo_box<>; using worst_t = soo_box_for; - STATIC_REQUIRE(::std::constructible_from, trivial_soo_box<>::allocator_type>); - STATIC_REQUIRE(::std::constructible_from); - STATIC_REQUIRE(::std::constructible_from); - STATIC_REQUIRE(::std::constructible_from); + STATIC_REQUIRE(constructible_from, trivial_soo_box<>::allocator_type>); + STATIC_REQUIRE(constructible_from); + STATIC_REQUIRE(constructible_from); + STATIC_REQUIRE(constructible_from); allocation_type_requirement_test(); } diff --git a/tests/src/type_traits/indexed_traits.cpp b/tests/src/type_traits/indexed_traits.cpp index b9f2c86..49fea22 100644 --- a/tests/src/type_traits/indexed_traits.cpp +++ b/tests/src/type_traits/indexed_traits.cpp @@ -27,8 +27,8 @@ SCENARIO("indexed traits", "[type traits][indexed traits]") { STATIC_REQUIRE(same_as()), int&>); STATIC_REQUIRE(same_as()), const int&>); - STATIC_REQUIRE(same_as()), int&&>); - STATIC_REQUIRE(same_as()), const int&&>); + STATIC_REQUIRE(same_as()), int&&>); + STATIC_REQUIRE(same_as()), const int&&>); STATIC_REQUIRE(same_as(values)), int&>); STATIC_REQUIRE(same_as, int&>); diff --git a/tests/src/type_traits/member.cpp b/tests/src/type_traits/member.cpp index 3a24a82..19447db 100644 --- a/tests/src/type_traits/member.cpp +++ b/tests/src/type_traits/member.cpp @@ -26,10 +26,10 @@ SCENARIO("member", "[type traits][member]") // NOLINT using mem_func_r = mem_p_func_t::result_t; using mem_func_args = mem_p_func_t::args_t; - STATIC_REQUIRE(std::same_as); - STATIC_REQUIRE(std::same_as); - STATIC_REQUIRE(std::same_as); - STATIC_REQUIRE(std::same_as); + STATIC_REQUIRE(same_as); + STATIC_REQUIRE(same_as); + STATIC_REQUIRE(same_as); + STATIC_REQUIRE(same_as); }; }; } \ No newline at end of file diff --git a/tests/src/type_traits/type_sequence.cpp b/tests/src/type_traits/type_sequence.cpp index 482c0c1..3403ca2 100644 --- a/tests/src/type_traits/type_sequence.cpp +++ b/tests/src/type_traits/type_sequence.cpp @@ -59,7 +59,7 @@ TEMPLATE_TEST_CASE_SIG( // NOLINT ) { STATIC_REQUIRE( - value_sequence_algo::find(basic_type_constant{}, std::equal_to{}) == Expect + value_sequence_algo::find(basic_type_constant{}, equal_to{}) == Expect ); } @@ -73,7 +73,7 @@ TEMPLATE_TEST_CASE_SIG( // NOLINT ) { STATIC_REQUIRE( - value_sequence_algo::count(type_constant{}, std::equal_to{}) == Expect + value_sequence_algo::count(type_constant{}, equal_to{}) == Expect ); } @@ -144,5 +144,5 @@ TEMPLATE_TEST_CASE_SIG( // NOLINT (0, test_seq, regular_type_sequence) ) { - STATIC_REQUIRE(same_as>, Expect>); + STATIC_REQUIRE(same_as>, Expect>); } diff --git a/tests/src/type_traits/value_sequence.cpp b/tests/src/type_traits/value_sequence.cpp index 2fed75f..bac88f6 100644 --- a/tests/src/type_traits/value_sequence.cpp +++ b/tests/src/type_traits/value_sequence.cpp @@ -137,8 +137,8 @@ TEMPLATE_TEST_CASE_SIG( // NOLINT ) { STATIC_REQUIRE( - value_sequence_algo:: - find(V, sequenced_invocables{std::ranges::equal_to{}, always_false}) == Expect + value_sequence_algo::find(V, sequenced_invocables{equal_to{}, always_false}) == + Expect ); } @@ -179,8 +179,7 @@ TEMPLATE_TEST_CASE_SIG( // NOLINT ) { STATIC_REQUIRE( - value_sequence_algo:: - count(V, sequenced_invocables{std::ranges::equal_to{}, always_false}) == + value_sequence_algo::count(V, sequenced_invocables{equal_to{}, always_false}) == Expect ); } @@ -217,7 +216,7 @@ SCENARIO("Scenario: value adjacent find", "[type traits]") // NOLINT STATIC_REQUIRE( // invocable< value_sequence_algo::adjacent_find_fn, - sequenced_invocables> // + sequenced_invocables> // ); } @@ -231,8 +230,7 @@ TEMPLATE_TEST_CASE_SIG( // NOLINT { STATIC_REQUIRE( // same_as< - value_sequence_algo:: - unique_t>, + value_sequence_algo::unique_t>, Expect> // ); } @@ -254,8 +252,8 @@ SCENARIO("tuple traits for regular value sequence", "[type traits][value sequence]") // NOLINT { STATIC_REQUIRE(tuple_size_v == 5); - STATIC_REQUIRE(std::same_as, int>); - STATIC_REQUIRE(std::same_as, size_t>); + STATIC_REQUIRE(same_as, int>); + STATIC_REQUIRE(same_as, size_t>); } SCENARIO("tuple traits for regular type sequence", diff --git a/tests/src/utility/dispatcher.cpp b/tests/src/utility/dispatcher.cpp index be8cc8c..d1fe6e1 100644 --- a/tests/src/utility/dispatcher.cpp +++ b/tests/src/utility/dispatcher.cpp @@ -18,7 +18,7 @@ SCENARIO("dispatcher basic requirements", "[utility][dispatcher]") // NOLINT dispatcher d{}; - STATIC_REQUIRE(!std::invocable); + STATIC_REQUIRE(!invocable); } GIVEN("noexcept dispatcher") diff --git a/tests/src/utility/forward_cast.cpp b/tests/src/utility/forward_cast.cpp index e2dcc86..8e91004 100644 --- a/tests/src/utility/forward_cast.cpp +++ b/tests/src/utility/forward_cast.cpp @@ -54,5 +54,10 @@ SCENARIO("forward cast", "[utility][forward cast]") STATIC_REQUIRE(same_as(v)), const t0&>); STATIC_REQUIRE(same_as(v)), t0&&>); STATIC_REQUIRE(same_as(v)), const t0&&>); + + STATIC_REQUIRE(same_as(v)), t0&>); + STATIC_REQUIRE(same_as(v)), const t0&>); + STATIC_REQUIRE(same_as(v)), t0&&>); + STATIC_REQUIRE(same_as(v)), const t0&&>); } } \ No newline at end of file diff --git a/tests/src/utility/value_wrapper.cpp b/tests/src/utility/value_wrapper.cpp index a21dc8f..033f3a9 100644 --- a/tests/src/utility/value_wrapper.cpp +++ b/tests/src/utility/value_wrapper.cpp @@ -31,9 +31,9 @@ SCENARIO("value_wrapper", "[utility][value wrapper]") // NOLINT [[maybe_unused]] value_wrapper wrapper{}; STATIC_REQUIRE(same_as); - STATIC_REQUIRE(same_as); + STATIC_REQUIRE(same_as); STATIC_REQUIRE(same_as); - STATIC_REQUIRE(same_as); + STATIC_REQUIRE(same_as); STATIC_REQUIRE( []