forked from Alepha/Alepha
Capabilities clauses can now be repeated.
This commit is contained in:
@ -36,7 +36,7 @@ namespace Alepha::Hydrogen
|
||||
or list_matches_v< cdr_t< List >, Capability >
|
||||
;
|
||||
};
|
||||
|
||||
|
||||
|
||||
template< typename Capability, typename List >
|
||||
concept CapabilityInList= list_matches_v< List, Capability >;
|
||||
@ -50,6 +50,44 @@ namespace Alepha::Hydrogen
|
||||
get_capability_list( const auto & );
|
||||
};
|
||||
|
||||
template< typename >
|
||||
struct extract_capability_list { using type= Nil; };
|
||||
|
||||
template< typename ... Caps >
|
||||
struct extract_capability_list< Capabilities< Caps... > >
|
||||
{
|
||||
using type= TypeList< Caps... >;
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
using extract_capability_list_t= typename extract_capability_list< T >::type;
|
||||
|
||||
template< typename ... >
|
||||
struct extract_capability_lists;
|
||||
|
||||
template< typename ... Args >
|
||||
using extract_capability_lists_t= typename extract_capability_lists< Args... >::type;
|
||||
|
||||
template< typename Arg >
|
||||
struct extract_capability_lists< Arg >
|
||||
{
|
||||
using type= extract_capability_list_t< Arg >;
|
||||
};
|
||||
|
||||
template< typename Arg, typename ... Args >
|
||||
struct extract_capability_lists< Arg, Args... >
|
||||
{
|
||||
using type= list_cat_t< extract_capability_list_t< Arg >, extract_capability_lists_t< Args... > >;
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
template< typename ... > class Basis,
|
||||
typename ... Args
|
||||
>
|
||||
extract_capability_lists_t< Args... >
|
||||
get_capability_list( Basis< Args... > );
|
||||
|
||||
namespace exports
|
||||
{
|
||||
template< typename T, typename Capability >
|
||||
@ -64,15 +102,6 @@ namespace Alepha::Hydrogen
|
||||
template< typename T, typename Cap >
|
||||
concept Capability= HasCapability< T, Cap >;
|
||||
}
|
||||
|
||||
struct capability_demo {};
|
||||
struct missing_capability_demo {};
|
||||
template< typename= Capabilities< capability_demo > >
|
||||
struct Example_base {};
|
||||
using Example= Example_base<>;
|
||||
static_assert( HasCapability< Example, capability_demo > == true );
|
||||
static_assert( HasCapability< Example, missing_capability_demo > == false );
|
||||
template< HasCapability< missing_capability_demo > C > void f( C ) {}
|
||||
}
|
||||
|
||||
namespace exports::Capabilities_m
|
||||
|
Reference in New Issue
Block a user