forked from Alepha/Alepha
Capabilities clauses can now be repeated.
This commit is contained in:
@ -39,6 +39,7 @@ add_subdirectory( Thread.test )
|
||||
add_subdirectory( assertion.test )
|
||||
add_subdirectory( Constness.test )
|
||||
add_subdirectory( Blob.test )
|
||||
add_subdirectory( Capabilities.test )
|
||||
|
||||
# Sample applications
|
||||
add_executable( example example.cc )
|
||||
|
@ -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
|
||||
|
27
Capabilities.test/0.cc
Normal file
27
Capabilities.test/0.cc
Normal file
@ -0,0 +1,27 @@
|
||||
static_assert( __cplusplus > 2020'99 );
|
||||
|
||||
#include "../Capabilities.h"
|
||||
|
||||
#include <Alepha/Testing/test.h>
|
||||
#include <Alepha/Testing/TableTest.h>
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
using namespace Alepha::exports::Capabilities_m;
|
||||
|
||||
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 ) {}
|
||||
}
|
||||
|
||||
|
||||
static auto init= Alepha::Utility::enroll <=[]
|
||||
{
|
||||
};
|
1
Capabilities.test/CMakeLists.txt
Normal file
1
Capabilities.test/CMakeLists.txt
Normal file
@ -0,0 +1 @@
|
||||
unit_test( 0 )
|
@ -18,12 +18,14 @@ namespace
|
||||
using namespace Alepha::Hydrogen::exports::comparisons_m;
|
||||
using namespace Alepha::Hydrogen::exports::Capabilities_m;
|
||||
|
||||
struct blast {};
|
||||
|
||||
template
|
||||
<
|
||||
typename= int,
|
||||
typename= Capabilities< comparable >,
|
||||
typename= float//,
|
||||
//typename= Capabilities< short >
|
||||
typename= Capabilities< blast >,
|
||||
typename= float,
|
||||
typename= Capabilities< comparable >
|
||||
>
|
||||
struct Date_core
|
||||
{
|
||||
@ -48,6 +50,7 @@ namespace
|
||||
|
||||
//static_assert( detail::is_capability_list_v< Capabilities< comparable > > );
|
||||
static_assert( Alepha::HasCapability< Date, Alepha::comparable > );
|
||||
static_assert( Alepha::HasCapability< Date, blast > );
|
||||
|
||||
template< template< typename > class op, typename T >
|
||||
constexpr bool
|
||||
|
Reference in New Issue
Block a user