All Classes Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Meta module

Provides utilities to aid template metaprogramming. More...

Classes

struct  gears::meta::indices< Ns >
 Represents an index sequence. More...
 
struct  gears::meta::build_indices< N, Ns >
 Creates an index sequence. More...
 
struct  gears::meta::identity< T >
 Identity meta function. More...
 
struct  gears::meta::void_<>
 Void meta function. More...
 
struct  gears::meta::Not< T >
 Logical Not meta function. More...
 
struct  gears::meta::Any< Args >
 Logical Or meta function. More...
 
struct  gears::meta::All< Args >
 Logical And meta function. More...
 
struct  gears::meta::class_of< T >
 Class of meta function. More...
 

Macros

#define GEARS_EXPAND(...)   void(::gears::meta::expand_detail::expander{((__VA_ARGS__), 0)...})
 Expands a variadic template. More...
 

Typedefs

template<typename... Args>
using gears::meta::EnableIf = Type< std::enable_if< All< Args...>::value, alias_detail::enabler >>
 Template alias for std::enable_if More...
 
template<typename... Args>
using gears::meta::DisableIf = Type< std::enable_if< meta::Not< All< Args...>>::value, alias_detail::enabler >>
 The negation of EnableIf.
 
template<typename T >
using gears::meta::Decay = Type< std::decay< T >>
 Template alias for std::decay.
 
template<typename T >
using gears::meta::RemoveRef = Type< std::remove_reference< T >>
 Template alias for std::remove_reference.
 
template<typename T >
using gears::meta::RemoveCV = Type< std::remove_cv< T >>
 Template alias for std::remove_cv.
 
template<typename T >
using gears::meta::RemoveConst = Type< std::remove_const< T >>
 Template alias for std::remove_const.
 
template<typename T >
using gears::meta::RemoveVolatile = Type< std::remove_volatile< T >>
 Template alias for std::remove_volatile.
 
template<typename T >
using gears::meta::RemoveExtents = Type< std::remove_all_extents< T >>
 Template alias for std::remove_all_extents.
 
template<typename T >
using gears::meta::RemovePointer = Type< std::remove_pointer< T >>
 Template alias for std::remove_pointer.
 
template<typename T >
using gears::meta::AddLValueRef = Type< std::add_lvalue_reference< T >>
 Template alias for std::add_lvalue_reference.
 
template<typename T >
using gears::meta::AddRValueRef = Type< std::add_rvalue_reference< T >>
 Template alias for std::add_rvalue_reference.
 
template<typename T >
using gears::meta::AddCV = Type< std::add_cv< T >>
 Template alias for std::add_cv.
 
template<typename T >
using gears::meta::AddConst = Type< std::add_const< T >>
 Template alias for std::add_const.
 
template<typename T >
using gears::meta::AddVolatile = Type< std::add_volatile< T >>
 Template alias for std::add_volatile.
 
template<typename T >
using gears::meta::AddPointer = Type< std::add_pointer< T >>
 Template alias for std::add_pointer.
 
template<typename T >
using gears::meta::MakeSigned = Type< std::make_signed< T >>
 Template alias for std::make_signed.
 
template<typename T >
using gears::meta::MakeUnsigned = Type< std::make_unsigned< T >>
 Template alias for std::make_unsigned.
 
template<typename T >
using gears::meta::Unqualified = RemoveCV< RemoveRef< T >>
 Template alias that removes all cv and ref qualifiers.
 
template<typename T >
using gears::meta::ValueType = typename Unqualified< T >::value_type
 Template alias to check for T::value_type.
 
template<typename T >
using gears::meta::StorageFor = Type< std::aligned_storage< sizeof(T), std::alignment_of< T >::value >>
 Template alias for std::aligned_storage with proper alignment.
 
template<typename T >
using gears::meta::Type = typename T::type
 Template alias for getting the type.
 
template<typename... Args>
using gears::meta::CommonType = Type< std::common_type< Args...>>
 Template alias for std::common_type.
 
template<typename T >
using gears::meta::UnderlyingType = Type< std::underlying_type< T >>
 Template alias for std::underlying_type.
 
template<typename T , T t>
using gears::meta::Const = std::integral_constant< T, t >
 Template alias for std::integral_constant.
 
template<int i>
using gears::meta::Integer = Const< int, i >
 Template alias for integer std::integral_constant.
 
template<typename... T>
using gears::meta::Void = Type< void_< T...>>
 Template alias for void meta function.
 
template<bool B>
using gears::meta::Bool = Const< bool, B >
 Template alias for std::integral_constant<bool, B>.
 
template<typename Condition , typename Then , typename Else >
using gears::meta::If = Type< std::conditional< Condition::value, Then, Else >>
 Template alias for std::conditional. More...
 
template<typename Condition , typename Then , typename Else >
using gears::meta::TypeIf = Type< If< Condition, Then, Else >>
 Lazy evaluation of If
 
template<typename Signature >
using gears::meta::ResultOf = Type< result_of_impl< Signature >>
 SFINAE-safe std::result_of alternative.
 
template<typename T >
using gears::meta::ClassOf = Type< class_of< T >>
 Template alias for class_of meta function.
 

Functions

template<typename T >
constexpr const T & gears::meta::as_const (T &t)
 Returns a non-const lvalue reference as a const lvalue reference. More...
 
template<typename T >
constexpr T && gears::meta::cforward (typename std::remove_reference< T >::type &&t) noexcept
 constexpr enabled alternative to std::forward. More...
 
template<typename T >
constexpr
std::remove_reference< T >
::type && 
gears::meta::cmove (T &&t) noexcept
 constexpr enabled alternative to std::move. More...
 

Detailed Description

This module provides metafunctions and other meta utilities that aid with template metaprogramming such as typedefs that help reduce the verbosity of working with templates.

Macro Definition Documentation

#define GEARS_EXPAND (   ...)    void(::gears::meta::expand_detail::expander{((__VA_ARGS__), 0)...})

Expands a variadic template. This is typically used in combination with indices and/or void functions.

Example:

template<typename T>
void f(T t) {
std::cout << t << '\n';
}
template<typename... Args>
void print(Args&&... args) {
GEARS_EXPAND(f(args));
}

Definition at line 54 of file expand.hpp.

Typedef Documentation

template<typename... Args>
using gears::meta::EnableIf = typedef Type<std::enable_if<All<Args...>::value, alias_detail::enabler>>

Template alias for std::enable_if. All arguments passed are evaluated as T::value. If any of the boolean arguments return false, then the entire thing returns false. Unlike regular std::enable_if, you cannot provide a return statement on it. This allows you to use it in template parameters.

Example:

template<typename T, meta::EnableIf<std::is_integral<T>> = meta::_>

Definition at line 52 of file meta/alias.hpp.

template<typename Condition , typename Then , typename Else >
using gears::meta::If = typedef Type<std::conditional<Condition::value, Then, Else>>

Template alias for std::conditional. Evaluates the Condition as if Condition::value was passed.

Example:

// passes the static_assert
static_assert(std::is_same<meta::If<std::is_integral<int>, double&, int&>, double&>::value, "...");

Definition at line 126 of file meta/meta.hpp.

Function Documentation

template<typename T >
constexpr const T& gears::meta::as_const ( T &  t)
Parameters
tlvalue reference to turn to const lvalue reference.
Returns
const lvalue reference.

Definition at line 257 of file meta/meta.hpp.

template<typename T >
constexpr T&& gears::meta::cforward ( typename std::remove_reference< T >::type &&  t)
noexcept
Parameters
tvariable to forward
Template Parameters
TType of parameter being forwarded.
Returns
static_cast<T&&>(t).

Definition at line 275 of file meta/meta.hpp.

template<typename T >
constexpr std::remove_reference<T>::type&& gears::meta::cmove ( T &&  t)
noexcept
Parameters
tvariable to move
Template Parameters
TType of parameter being enabled to be moved.
Returns
static_cast<RemoveRef<T>&&>(t).

Definition at line 289 of file meta/meta.hpp.