From 304640d76b9417fd17df1476a8c4d50ae4efb635 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Tue, 26 Oct 2021 02:05:57 -0400 Subject: [PATCH] Experiment with `constexpr` traits in `enable_if`. So the `constexpr` traits do not really look better here. But they may be better for writing linear code in complex trait processing, as opposed to complicated recursive code. Still to be determined. However, If I stay with this and if `std::find_if` and friends are `constexpr`, then the `Mata` algorithms can be removed, and `std::` forms will just work. That's a nice bonus. Otherwise, we need something more like `boost::mpl`, which is kinda annoying. Still, `Meta::Container::vector` is very nice -- it side-steps some issues with using `std::tuple` as a type-list. --- comparisons.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/comparisons.h b/comparisons.h index 2b0234d..579fea4 100644 --- a/comparisons.h +++ b/comparisons.h @@ -33,10 +33,12 @@ namespace Alepha::Hydrogen } template< typename T > - constexpr bool has_comparable_capability_v= has_capability_v< std::decay_t< T >, comparable >; + constexpr bool has_comparable_capability_v= has_capability( Meta::type_value< std::decay_t< T > >{}, comparable_capability ); template< typename T > - struct has_comparable_capability : std::bool_constant< has_comparable_capability_v< T > > {}; + struct has_comparable_capability_s : std::bool_constant< has_comparable_capability_v< T > > {}; + + inline constexpr Meta::trait< has_comparable_capability_s > has_comparable_capability; // Spaceship lens support @@ -53,7 +55,7 @@ namespace Alepha::Hydrogen template < typename T, - typename= std::enable_if_t< has_comparable_capability_v< T > >, + typename= std::enable_if_t< has_comparable_capability( Meta::type_value< T >{} ) >, typename= std::enable_if_t< has_spaceship_lens_member_v< T > >, overload< __LINE__ > = nullptr >