OSVR-Core  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
osvr::typepack Namespace Reference

A simple argument-pack-based metaprogramming library, inspired by and based partially on https://ericniebler.github.io/meta. More...

Classes

struct  always
 A Alias Class that always returns T. More...
 
struct  compose
 Compose the Alias Classes Fs in the parameter pack Ts. More...
 
struct  defer
 
struct  list
 A wrapper for a template parameter pack of types. More...
 
struct  quote
 
class  TypeKeyedBase
 
class  TypeKeyedMap
 A class that uses types as an index into a container with uniform-typed contents, somewhat like a map except all elements are default-constructed rather than having an optional "not set" status. (You may emulate this by providing a specialization of boost::optional<> as your value type.) More...
 
class  TypeKeyedTuple
 Provides a data structure where a value of heterogeneous data types may be stored at runtime for each of the "key" types in a list. The runtime data type stored is computed by an alias class. More...
 

Typedefs

template<typename... Bools>
using and_ = t_< detail::and_impl< Bools...>>
 
template<typename F , typename... Args>
using apply = typename F::template apply< Args...>
 Apply an alias class.
 
template<typename F , typename Args >
using apply_list = apply< detail::apply_list_< F, Args >>
 Apply an alias class, exploding the list of args.
 
template<bool V>
using bool_ = std::integral_constant< bool, V >
 Alias template to simplify creating a boolean integral constant.
 
template<typename... Ts>
using coerce_list = t_< list< Ts...>>
 Will turn whatever is passed into it into the simplest list.
 
template<typename... Lists>
using concat = t_< detail::concat_< Lists...>>
 
template<typename Haystack , typename Needle >
using contains = apply_list< quote< or_ >, transform< Haystack, detail::is_< Needle >>>
 Determines if type Needle is in the list Haystack - is an alias for a type that inherits std::true_type or std::false_type.
 
template<typename List , typename Needle >
using find_first = t_< detail::find_first_impl< Needle, 0, List >>
 Returns the zero-based index of the first instance of Needle in List. Will fail to compile if not found.
 
template<typename List , typename State , typename Fun >
using fold = t_< detail::fold_< List, State, Fun >>
 Fold the list (right) with the given alias class and initial state.
 
template<typename T >
using has_type = t_< detail::has_type_< T >>
 
template<typename... Args>
using if_ = t_< detail::if_impl< Args...>>
 
template<bool If, typename... Args>
using if_c = t_< detail::if_impl< bool_< If >, Args...>>
 Select one type or another depending on a compile-time Boolean value.
 
template<typename Bool >
using not_ = bool_<!Bool::value >
 Logical not on a single boolean.
 
template<typename... Bools>
using or_ = t_< detail::or_impl< Bools...>>
 
template<template< typename...> class C>
using quote_trait = compose< quote< t_ >, quote< C >>
 Turn a trait C into a Alias Class.
 
template<typename... Ts>
using size = detail::size< coerce_list< Ts...>>
 Get the size of a list (number of elements.)
 
template<typename... Ts>
using length = size< coerce_list< Ts...>>
 Synonym for typepack::size.
 
template<std::size_t V>
using size_t_ = std::integral_constant< std::size_t, V >
 Alias template to simplify creating an integral constant of size_t.
 
template<typename... List>
using head = typename detail::split_list_< List...>::head
 Get the first element of a list.
 
template<typename... List>
using tail = typename detail::split_list_< List...>::tail
 Get the list without its first element.
 
template<typename T >
using t_ = typename T::type
 A convenience alias template to extract the nested type within the supplied T. More...
 
template<typename List , typename Fun >
using transform = t_< detail::transform_< List, Fun >>
 
template<typename... Ts>
using void_ = apply< always< void >, Ts...>
 An alias for void.
 

Functions

template<typename List , typename F , typename... Args>
void for_each_type (F &&f, Args &&...args)
 

Detailed Description

A simple argument-pack-based metaprogramming library, inspired by and based partially on https://ericniebler.github.io/meta.

It includes an as-needed subset of the features of meta, modified as needed to build on MSVC 2013, as well as additional functionality not found in meta.

Typedef Documentation

template<typename... Bools>
using osvr::typepack::and_ = typedef t_<detail::and_impl<Bools...>>

Logically and together all the integral constant-wrapped Boolean parameters, with short-circuiting.

Definition at line 61 of file And.h.

template<typename... Lists>
using osvr::typepack::concat = typedef t_<detail::concat_<Lists...>>

Concatenates several lists into a single list.

Precondition
The parameters must all be instantiations of typepack::list.
Complexity
$ O(L) $ where $ L $ is the number of lists in the list of lists.

Definition at line 75 of file Concat.h.

template<typename T >
using osvr::typepack::has_type = typedef t_<detail::has_type_<T>>

An alias for std::true_type if T::type exists and names a type; otherwise, it's an alias for std::false_type.

Definition at line 57 of file HasType.h.

template<typename... Args>
using osvr::typepack::if_ = typedef t_<detail::if_impl<Args...>>

Select one type or another depending on a compile-time Boolean integral constant type.

Definition at line 61 of file If.h.

template<typename... Bools>
using osvr::typepack::or_ = typedef t_<detail::or_impl<Bools...>>

Logically or together all the integral constant-wrapped Boolean parameters, with short-circuiting.

Definition at line 58 of file Or.h.

template<typename T >
using osvr::typepack::t_ = typedef typename T::type

A convenience alias template to extract the nested type within the supplied T.

The name was chosen to parallel how the traits in C++14 (like std::enable_if) have been complemented by aliases ending in _t (like std::enable_if_t<COND> being equivalent to typename std::enable_if<COND>::type)

Note that the name is t_, unlike in meta where the semi-illegal name _t is used. (Leading underscores are between risky and not permitted.)

Definition at line 52 of file T.h.

template<typename List , typename Fun >
using osvr::typepack::transform = typedef t_<detail::transform_<List, Fun>>

Given a list and an alias class, apply the alias class to each element in the list and return the results in a list.

Definition at line 54 of file Transform.h.

Function Documentation

template<typename List , typename F , typename... Args>
void osvr::typepack::for_each_type ( F &&  f,
Args &&...  args 
)
inline

Run-time operation on a type list: given a function object, a type list, and optional arguments to be forwarded to the function call, construct each type in the type list in turn and call the function-call-operator of your functor with it (and your optional additional arguments).

Definition at line 81 of file ForEachType.h.