Speclib  0.1.2
The library for writing better CUDA libraries
sp::TypeSetImpl< Members > Class Template Reference

Represents a set of types, based on sorted lists. More...

#include <TypeSet.hpp>

Public Types

using ThisType = TypeSetImpl< Members >
 
using AsList = Members
 
template<typename OtherSet >
using unionWith = TypeSetImpl< typename Members::template uniqueMerge< typename OtherSet::AsList > >
 Union this set with another. More...
 
template<typename OtherSet >
using intersectionWith = TypeSetImpl< decltype(intersectHelper< Members, typename OtherSet::AsList >())>
 Intersect this set with another. More...
 
template<typename OtherSet >
using subtract = TypeSetImpl< decltype(subtractHelper< Members, typename OtherSet::AsList >())>
 Subtract another set from this one. More...
 
template<typename I >
using add = unionWith< TypeSetImpl< TypeList< I > > >
 Add an element to the set. More...
 
template<typename I >
using remove = subtract< TypeSetImpl< TypeList< I > > >
 Remove an element from the set. More...
 
template<template< typename > typename Lambda>
using map = TypeSetImpl< typename Members::template map< Lambda > >
 Functional map. More...
 
template<typename Defer = Members>
using head = typename Defer::template get< 0 >
 Get the first element. More...
 
template<typename Defer = Members>
using tail = TypeSetImpl< typename Defer::template slice< 1 > >
 The set minus the first element (combine with first to iterate sets). More...
 

Static Public Member Functions

template<typename T >
static constexpr bool contains ()
 O(log(n)) More...
 
template<typename List1 , typename List2 , int I1 = 0, int I2 = 0, typename NewList = TypeList<>>
constexpr static auto intersectHelper ()
 Intersect two sorted lists of unique elements. More...
 
template<typename List1 , typename List2 , int I1 = 0, int I2 = 0, typename NewList = TypeList<>>
constexpr static auto subtractHelper ()
 Subtract List2 from List2. Both lists are sorted lists of unique elements. More...
 

Static Public Attributes

constexpr static int Size = Members::Size
 
constexpr static bool Empty = Size == 0
 

Detailed Description

template<typename Members>
class sp::TypeSetImpl< Members >

Represents a set of types, based on sorted lists.

The types being stored must be sortable.

You probably want to access this using the TypeSet alias, and construct them through the AsTypeSet alias.

Template Parameters
MembersA sorted sp::TypeList of the members of the set.

Member Typedef Documentation

◆ add

template<typename Members >
template<typename I >
using sp::TypeSetImpl< Members >::add = unionWith<TypeSetImpl<TypeList<I> >>

Add an element to the set.

◆ head

template<typename Members >
template<typename Defer = Members>
using sp::TypeSetImpl< Members >::head = typename Defer::template get<0>

Get the first element.

◆ intersectionWith

template<typename Members >
template<typename OtherSet >
using sp::TypeSetImpl< Members >::intersectionWith = TypeSetImpl<decltype(intersectHelper<Members, typename OtherSet::AsList>())>

Intersect this set with another.

◆ map

template<typename Members >
template<template< typename > typename Lambda>
using sp::TypeSetImpl< Members >::map = TypeSetImpl<typename Members::template map<Lambda> >

Functional map.

◆ remove

template<typename Members >
template<typename I >
using sp::TypeSetImpl< Members >::remove = subtract<TypeSetImpl<TypeList<I> >>

Remove an element from the set.

◆ subtract

template<typename Members >
template<typename OtherSet >
using sp::TypeSetImpl< Members >::subtract = TypeSetImpl<decltype(subtractHelper<Members, typename OtherSet::AsList>())>

Subtract another set from this one.

◆ tail

template<typename Members >
template<typename Defer = Members>
using sp::TypeSetImpl< Members >::tail = TypeSetImpl<typename Defer::template slice<1> >

The set minus the first element (combine with first to iterate sets).

◆ unionWith

template<typename Members >
template<typename OtherSet >
using sp::TypeSetImpl< Members >::unionWith = TypeSetImpl<typename Members::template uniqueMerge<typename OtherSet::AsList> >

Union this set with another.

Member Function Documentation

◆ contains()

template<typename Members >
template<typename T >
static constexpr bool sp::TypeSetImpl< Members >::contains ( )
staticconstexpr

O(log(n))

◆ intersectHelper()

template<typename Members >
template<typename List1 , typename List2 , int I1 = 0, int I2 = 0, typename NewList = TypeList<>>
constexpr static auto sp::TypeSetImpl< Members >::intersectHelper ( )
staticconstexpr

Intersect two sorted lists of unique elements.

◆ subtractHelper()

template<typename Members >
template<typename List1 , typename List2 , int I1 = 0, int I2 = 0, typename NewList = TypeList<>>
constexpr static auto sp::TypeSetImpl< Members >::subtractHelper ( )
staticconstexpr

Subtract List2 from List2. Both lists are sorted lists of unique elements.