forked from Alepha/Alepha
I think this makes capabilities much simpler and more reliable.
But the capabilities are now limited to a single param -- Time to change that?
This commit is contained in:
25
type_lisp.h
25
type_lisp.h
@ -5,6 +5,7 @@ static_assert( __cplusplus > 2020'99 );
|
||||
#include <Alepha/Alepha.h>
|
||||
|
||||
#include <type_traits>
|
||||
#include <tuple>
|
||||
|
||||
namespace Alepha::Hydrogen ::detail:: type_lisp_m
|
||||
{
|
||||
@ -74,18 +75,28 @@ namespace Alepha::Hydrogen ::detail:: type_lisp_m
|
||||
using cdr_t= typename cdr_impl< List >::type;
|
||||
}
|
||||
|
||||
template< typename List, typename Element >
|
||||
struct list_contains
|
||||
{
|
||||
static const bool value= std::is_same_v< Element, car_t< List > > or list_contains< cdr_t< List >, Element >::value;
|
||||
};
|
||||
|
||||
template< typename Element >
|
||||
struct list_contains< Nil, Element > : std::false_type {};
|
||||
|
||||
namespace exports
|
||||
{
|
||||
template< typename List, typename Element >
|
||||
constexpr bool list_contains_v=
|
||||
std::is_same_v< Element, car_t< List > >
|
||||
or
|
||||
list_contains_v< cdr_t< List >, Element >;
|
||||
|
||||
template< typename Element >
|
||||
constexpr bool list_contains_v< Nil, Element >{};
|
||||
constexpr bool list_contains_v= list_contains< List, Element >::value;
|
||||
}
|
||||
|
||||
struct Alpha;
|
||||
struct Beta;
|
||||
struct Gamma;
|
||||
static_assert( list_contains_v< TypeList< Alpha, Beta >, Alpha > );
|
||||
static_assert( list_contains_v< TypeList< Alpha, Beta >, Beta > );
|
||||
static_assert( not list_contains_v< TypeList< Alpha, Beta >, Gamma > );
|
||||
|
||||
template< typename Element, typename List >
|
||||
struct cons;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user