proxygen
|
Go to the source code of this file.
Classes | |
struct | folly::detail::TypeList< Ts > |
struct | folly::detail::Type< T > |
struct | folly::detail::Empty |
class | folly::detail::MetaDefer< C, Ts > |
struct | folly::detail::MetaDefer< C, Ts >::Result |
struct | folly::detail::MetaCompose< P, Q > |
struct | folly::detail::MetaIdentity |
struct | folly::detail::MetaQuote< C > |
struct | folly::detail::MetaBindFront< Fn, Ts > |
struct | folly::detail::MetaBindBack< Fn, Ts > |
struct | folly::detail::MetaFlip< Fn > |
struct | folly::detail::impl::Inherit_< List > |
struct | folly::detail::impl::Inherit_< TypeList< Ts... > > |
Namespaces | |
folly | |
—— Concurrent Priority Queue Implementation —— | |
folly::detail | |
folly::detail::impl | |
Typedefs | |
template<bool B> | |
using | folly::detail::Bool = bool_constant< B > |
using | folly::detail::True = std::true_type |
using | folly::detail::False = std::false_type |
template<class Fn , class... Ts> | |
using | folly::detail::MetaApply = typename Fn::template apply< Ts... > |
template<bool If_, class Then , class Else > | |
using | folly::detail::If = MetaApply< impl::If_< If_ >, Then, Else > |
template<template< class... > class C> | |
using | folly::detail::MetaQuoteTrait = MetaCompose< MetaQuote< _t >, MetaQuote< C >> |
template<class Fn > | |
using | folly::detail::MetaCurry = MetaCompose< Fn, MetaQuote< TypeList >> |
template<class Fn > | |
using | folly::detail::MetaUncurry = MetaBindBack< MetaQuote< MetaApply >, Fn > |
template<class List , class... Ts> | |
using | folly::detail::TypePushBack = MetaApply< List, MetaBindBack< MetaQuote< TypeList >, Ts... >> |
template<class List , class... Ts> | |
using | folly::detail::TypePushFront = MetaApply< List, MetaBindFront< MetaQuote< TypeList >, Ts... >> |
template<class Fn , class List > | |
using | folly::detail::MetaUnpack = MetaApply< List, Fn > |
template<class List , class Fn > | |
using | folly::detail::TypeTransform = MetaApply< List, impl::TypeTransform_< Fn >> |
template<class List , class State , class Fn > | |
using | folly::detail::TypeFold = MetaApply< MetaApply< List, impl::FoldR_< Fn >>, State > |
template<class List , class State , class Fn > | |
using | folly::detail::TypeReverseFold = MetaApply< MetaApply< List, impl::FoldL_< Fn >>, State > |
template<class List > | |
using | folly::detail::Inherit = impl::Inherit_< List > |
template<class List > | |
using | folly::detail::TypeUnique = TypeFold< List, TypeList<>, impl::Unique_ > |
template<class List > | |
using | folly::detail::TypeReverseUnique = TypeReverseFold< List, TypeList<>, MetaFlip< impl::Unique_ >> |
template<class T > | |
using | folly::detail::AsTypeList = _t< impl::AsTypeList_< T >> |
template<class List > | |
using | folly::detail::TypeJoin = MetaApply< TypeFold< List, MetaQuote< TypeList >, impl::Join_ >> |
template<class... Ts> | |
using | folly::detail::TypeConcat = TypeJoin< TypeList< Ts... >> |
The file contains facilities for manipulating lists of types, and for defining and composing operations over types.
The type-operations behave like compile-time functions: they accept types as input and produce types as output. A simple example is a template alias, like std::add_pointer_t
. However, templates are not themselves first class citizens of the language; they cannot be easily "returned" from a metafunction, and passing them to a metafunction is awkward and often requires the user to help the C++ parser by adding hints like typename
and template
to disambiguate the syntax. That makes higher-ordered metaprogramming difficult. (There is no simple way to e.g., compose two template aliases and pass the result as an argument to another template.)
Instead, we wrap template aliases in a ordinary class, which can be passed and returned simply from metafunctions. This is like Boost.MPL's notion of a "metafunction class"[1], and we adopt that terminology here.
For the Folly.TypeList library, a metafunction class is a protocol that all the components of Folly.TypeList expect and agree upon. It is a class type that has a nested template alias called Apply
. So for instance, std::add_pointer_t
as a Folly metafunction class would look like this:
struct AddPointer { template <class T> using apply = T*; };
Folly.TypeList gives a simple way to "lift" an ordinary template alias into a metafunction class: MetaQuote
. The above AddPointer
could instead be written as:
using AddPointer = folly::MetaQuote<std::add_pointer_t>;
A word about naming. Components in Folly.TypeList fall into two buckets: utilities for manipulating lists of types, and utilities for manipulating metafunction classes. The former have names that start with Type
, as in TypeList
and TypeTransform
. The latter have names that start with Meta
, as in MetaQuote
and MetaApply
.
[1] Boost.MPL Metafunction Class: http://www.boost.org/libs/mpl/doc/refmanual/metafunction-class.html
Definition in file TypeList.h.