@@ -1764,9 +1764,7 @@ constexpr auto is( X const& x ) -> auto {
1764
1764
}
1765
1765
}
1766
1766
return type_find_if (x, [&]<typename It>(It const &) -> bool {
1767
- if constexpr (It::index < 20 ) {
1768
- if (x.index () == It::index) { return std::is_same_v<C, std::variant_alternative_t <It::index, X>>;}
1769
- }
1767
+ if (x.index () == It::index) { return std::is_same_v<C, std::variant_alternative_t <It::index, X>>;}
1770
1768
return false ;
1771
1769
}) != std::variant_npos;
1772
1770
}
@@ -1822,13 +1820,11 @@ inline constexpr auto is( auto const& x, auto&& value ) -> bool
1822
1820
}
1823
1821
else if constexpr (specialization_of_template<decltype (x), std::variant> ) {
1824
1822
return type_find_if (x, [&]<typename It>(It const &) -> bool {
1825
- if constexpr (It::index < 20 ) { // TODO: remove after refactor
1826
- if (x.index () == It::index) {
1827
- if constexpr (valid_predicate<decltype (value), decltype (std::get<It::index>(x))>) {
1828
- return value (std::get<It::index>(x));
1829
- } else if constexpr ( requires { bool {std::get<It::index>(x) == value}; } ) {
1830
- return std::get<It::index>(x) == value;
1831
- }
1823
+ if (x.index () == It::index) {
1824
+ if constexpr (valid_predicate<decltype (value), decltype (std::get<It::index>(x))>) {
1825
+ return value (std::get<It::index>(x));
1826
+ } else if constexpr ( requires { bool {std::get<It::index>(x) == value}; } ) {
1827
+ return std::get<It::index>(x) == value;
1832
1828
}
1833
1829
}
1834
1830
return false ;
@@ -2014,9 +2010,7 @@ auto as(auto&& x CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT_AS) -> decltype(auto)
2014
2010
else if constexpr (specialization_of_template<decltype (x), std::variant>) {
2015
2011
constness_like_t <C, decltype (x)>* ptr = nullptr ;
2016
2012
type_find_if (CPP2_FORWARD (x), [&]<typename It>(It const &) -> bool {
2017
- if constexpr (It::index < 20 ) {
2018
- if constexpr (std::is_same_v< typename It::type, C >) { if (CPP2_FORWARD (x).index () == It::index) { ptr = &std::get<It::index>(x); return true ; } };
2019
- }
2013
+ if constexpr (std::is_same_v< typename It::type, C >) { if (CPP2_FORWARD (x).index () == It::index) { ptr = &std::get<It::index>(x); return true ; } };
2020
2014
return false ;
2021
2015
});
2022
2016
if (!ptr) { Throw ( std::bad_variant_access (), " 'as' cast failed for 'variant'" ); }
0 commit comments