diff --git a/ROADMAP.md b/ROADMAP.md index 28f0b08..1978c68 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -6,7 +6,6 @@ - fix all includes to work with the library more flexible - test and support shared libraries - add debug type names -- auto register destructor without class_ ## Version 1.0 diff --git a/develop/singles/headers/meta.hpp/meta_all.hpp b/develop/singles/headers/meta.hpp/meta_all.hpp index 4a1ec69..6c9d38c 100644 --- a/develop/singles/headers/meta.hpp/meta_all.hpp +++ b/develop/singles/headers/meta.hpp/meta_all.hpp @@ -10,11 +10,11 @@ #include #include #include +#include #include #include #include #include -#include #include #include #include @@ -8991,7 +8991,7 @@ namespace meta_hpp::detail namespace meta_hpp::detail { template < typename T > - requires std::is_copy_constructible_v + requires requires(const T& v) { uvalue{v}; } struct copy_traits { uvalue operator()(const T& v) const { return uvalue{v}; @@ -9014,26 +9014,10 @@ namespace meta_hpp::detail namespace meta_hpp::detail { template < typename T > - requires std::is_copy_constructible_v - struct deref_traits { - uvalue operator()(T* v) const { - return v != nullptr ? uvalue{*v} : uvalue{}; - } - }; - - template < typename T > - requires std::is_copy_constructible_v - struct deref_traits> { - uvalue operator()(const std::shared_ptr& v) const { - return v != nullptr ? uvalue{*v} : uvalue{}; - } - }; - - template < typename T > - requires std::is_copy_constructible_v - struct deref_traits> { - uvalue operator()(const std::unique_ptr& v) const { - return v != nullptr ? uvalue{*v} : uvalue{}; + requires requires(const T& v) { uvalue{*v}; } + struct deref_traits { + uvalue operator()(const T& v) const { + return uvalue{*v}; } }; } @@ -9053,51 +9037,10 @@ namespace meta_hpp::detail namespace meta_hpp::detail { template < typename T > - requires std::is_copy_constructible_v - struct index_traits { - uvalue operator()(T* v, std::size_t i) const { - // NOLINTNEXTLINE(*-pointer-arithmetic) - return v != nullptr ? uvalue{v[i]} : uvalue{}; - } - }; - - template < typename T, std::size_t Size > - requires std::is_copy_constructible_v - struct index_traits> { - uvalue operator()(const std::array& v, std::size_t i) const { - return i < v.size() ? uvalue{v[i]} : uvalue{}; - } - }; - - template < typename T, typename Allocator > - requires std::is_copy_constructible_v - struct index_traits> { - uvalue operator()(const std::deque& v, std::size_t i) { - return i < v.size() ? uvalue{v[i]} : uvalue{}; - } - }; - - template < typename T, std::size_t Extent > - requires std::is_copy_constructible_v - struct index_traits> { - uvalue operator()(const std::span& v, std::size_t i) const { - return i < v.size() ? uvalue{v[i]} : uvalue{}; - } - }; - - template < typename T, typename Traits, typename Allocator > - requires std::is_copy_constructible_v - struct index_traits> { - uvalue operator()(const std::basic_string& v, std::size_t i) const { - return i < v.size() ? uvalue{v[i]} : uvalue{}; - } - }; - - template < typename T, typename Allocator > - requires std::is_copy_constructible_v - struct index_traits> { - uvalue operator()(const std::vector& v, std::size_t i) { - return i < v.size() ? uvalue{v[i]} : uvalue{}; + requires requires(const T& v, std::size_t i) { uvalue{v[i]}; } + struct index_traits { + uvalue operator()(const T& v, std::size_t i) const { + return uvalue{v[i]}; } }; } diff --git a/develop/untests/meta_issues/random_issue_3.cpp b/develop/untests/meta_issues/random_issue_3.cpp index d79cbf0..91c2460 100644 --- a/develop/untests/meta_issues/random_issue_3.cpp +++ b/develop/untests/meta_issues/random_issue_3.cpp @@ -34,7 +34,7 @@ TEST_CASE("meta/meta_issues/random/3") { { meta::uvalue v{&int_func}; - CHECK_FALSE(v.has_deref_op()); + CHECK(v.has_deref_op()); CHECK(v.get_type() == meta::resolve_type()); CHECK((v.as() == &int_func)); } diff --git a/develop/untests/meta_utilities/value_tests.cpp b/develop/untests/meta_utilities/value_tests.cpp index f5337c4..cb776d3 100644 --- a/develop/untests/meta_utilities/value_tests.cpp +++ b/develop/untests/meta_utilities/value_tests.cpp @@ -584,9 +584,6 @@ TEST_CASE("meta/meta_utilities/value") { CHECK(meta::uvalue{p1}.has_deref_op()); CHECK(meta::uvalue{p2}.has_deref_op()); - - CHECK_FALSE(*meta::uvalue{p1}); - CHECK_FALSE(*meta::uvalue{p2}); } { ivec2 v{1,2}; @@ -657,8 +654,6 @@ TEST_CASE("meta/meta_utilities/value/arrays") { meta::uvalue v{arr}; CHECK(v.get_type() == meta::resolve_type()); CHECK(v.has_index_op()); - - CHECK_FALSE(v[0]); } } @@ -678,8 +673,6 @@ TEST_CASE("meta/meta_utilities/value/arrays") { meta::uvalue v{arr}; CHECK(v.get_type() == meta::resolve_type()); CHECK(v.has_index_op()); - - CHECK_FALSE(v[0]); } } @@ -691,18 +684,6 @@ TEST_CASE("meta/meta_utilities/value/arrays") { CHECK(v[0].as() == 1); CHECK(v[1].as() == 2); CHECK(v[2].as() == 3); - CHECK_FALSE(v[3]); - } - - SUBCASE("std::deque") { - const meta::uvalue v{std::deque{1,2,3}}; - CHECK(v.get_type() == meta::resolve_type>()); - CHECK(v.has_index_op()); - - CHECK(v[0].as() == 1); - CHECK(v[1].as() == 2); - CHECK(v[2].as() == 3); - CHECK_FALSE(v[3]); } SUBCASE("std::string") { @@ -713,7 +694,6 @@ TEST_CASE("meta/meta_utilities/value/arrays") { CHECK(v[0].as() == 'h'); CHECK(v[1].as() == 'i'); CHECK(v[2].as() == '!'); - CHECK_FALSE(v[3]); } SUBCASE("std::span") { @@ -725,7 +705,6 @@ TEST_CASE("meta/meta_utilities/value/arrays") { CHECK(v[0].as() == 1); CHECK(v[1].as() == 2); CHECK(v[2].as() == 3); - CHECK_FALSE(v[3]); } SUBCASE("std::vector") { @@ -736,7 +715,6 @@ TEST_CASE("meta/meta_utilities/value/arrays") { CHECK(v[0].as() == 1); CHECK(v[1].as() == 2); CHECK(v[2].as() == 3); - CHECK_FALSE(v[3]); } } diff --git a/headers/meta.hpp/meta_base/base.hpp b/headers/meta.hpp/meta_base/base.hpp index ff84e40..b70fe05 100644 --- a/headers/meta.hpp/meta_base/base.hpp +++ b/headers/meta.hpp/meta_base/base.hpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/headers/meta.hpp/meta_detail/value_traits/copy_traits.hpp b/headers/meta.hpp/meta_detail/value_traits/copy_traits.hpp index af24cfd..1fd8d52 100644 --- a/headers/meta.hpp/meta_detail/value_traits/copy_traits.hpp +++ b/headers/meta.hpp/meta_detail/value_traits/copy_traits.hpp @@ -24,7 +24,7 @@ namespace meta_hpp::detail namespace meta_hpp::detail { template < typename T > - requires std::is_copy_constructible_v + requires requires(const T& v) { uvalue{v}; } struct copy_traits { uvalue operator()(const T& v) const { return uvalue{v}; diff --git a/headers/meta.hpp/meta_detail/value_traits/deref_traits.hpp b/headers/meta.hpp/meta_detail/value_traits/deref_traits.hpp index 5f5e03f..2e626f8 100644 --- a/headers/meta.hpp/meta_detail/value_traits/deref_traits.hpp +++ b/headers/meta.hpp/meta_detail/value_traits/deref_traits.hpp @@ -24,26 +24,10 @@ namespace meta_hpp::detail namespace meta_hpp::detail { template < typename T > - requires std::is_copy_constructible_v - struct deref_traits { - uvalue operator()(T* v) const { - return v != nullptr ? uvalue{*v} : uvalue{}; - } - }; - - template < typename T > - requires std::is_copy_constructible_v - struct deref_traits> { - uvalue operator()(const std::shared_ptr& v) const { - return v != nullptr ? uvalue{*v} : uvalue{}; - } - }; - - template < typename T > - requires std::is_copy_constructible_v - struct deref_traits> { - uvalue operator()(const std::unique_ptr& v) const { - return v != nullptr ? uvalue{*v} : uvalue{}; + requires requires(const T& v) { uvalue{*v}; } + struct deref_traits { + uvalue operator()(const T& v) const { + return uvalue{*v}; } }; } diff --git a/headers/meta.hpp/meta_detail/value_traits/index_traits.hpp b/headers/meta.hpp/meta_detail/value_traits/index_traits.hpp index 5217e27..52507f6 100644 --- a/headers/meta.hpp/meta_detail/value_traits/index_traits.hpp +++ b/headers/meta.hpp/meta_detail/value_traits/index_traits.hpp @@ -24,51 +24,10 @@ namespace meta_hpp::detail namespace meta_hpp::detail { template < typename T > - requires std::is_copy_constructible_v - struct index_traits { - uvalue operator()(T* v, std::size_t i) const { - // NOLINTNEXTLINE(*-pointer-arithmetic) - return v != nullptr ? uvalue{v[i]} : uvalue{}; - } - }; - - template < typename T, std::size_t Size > - requires std::is_copy_constructible_v - struct index_traits> { - uvalue operator()(const std::array& v, std::size_t i) const { - return i < v.size() ? uvalue{v[i]} : uvalue{}; - } - }; - - template < typename T, typename Allocator > - requires std::is_copy_constructible_v - struct index_traits> { - uvalue operator()(const std::deque& v, std::size_t i) { - return i < v.size() ? uvalue{v[i]} : uvalue{}; - } - }; - - template < typename T, std::size_t Extent > - requires std::is_copy_constructible_v - struct index_traits> { - uvalue operator()(const std::span& v, std::size_t i) const { - return i < v.size() ? uvalue{v[i]} : uvalue{}; - } - }; - - template < typename T, typename Traits, typename Allocator > - requires std::is_copy_constructible_v - struct index_traits> { - uvalue operator()(const std::basic_string& v, std::size_t i) const { - return i < v.size() ? uvalue{v[i]} : uvalue{}; - } - }; - - template < typename T, typename Allocator > - requires std::is_copy_constructible_v - struct index_traits> { - uvalue operator()(const std::vector& v, std::size_t i) { - return i < v.size() ? uvalue{v[i]} : uvalue{}; + requires requires(const T& v, std::size_t i) { uvalue{v[i]}; } + struct index_traits { + uvalue operator()(const T& v, std::size_t i) const { + return uvalue{v[i]}; } }; }