Boost.Hana  1.0.2 Your standard library for metaprogramming
boost::hana Namespace Reference

Namespace containing everything in the library. More...

## Namespaces

literals
Namespace containing C++14 user-defined literals provided by Hana.

## Classes

struct  basic_tuple
Stripped down version of hana::tuple. More...

struct  basic_tuple_tag
Tag representing hana::basic_tuple. More...

struct  basic_type
Base class of hana::type; used for pattern-matching. More...

struct  common
Metafunction returning the common data type between two data types. More...

struct  default_
Mark a tag-dispatched method implementation as a default implementation. More...

struct  embedding
Marks a conversion between data types as being an embedding. More...

struct  has_common
Metafunction returning whether two data types share a common data type. More...

struct  integral_constant
Compile-time value of an integral type. More...

struct  integral_constant_tag
Tag representing hana::integral_constant. More...

struct  IntegralConstant
The IntegralConstant concept represents compile-time integral values. More...

struct  is_convertible
Returns whether there is a Hana-conversion from a data type to another. More...

struct  is_default
Returns whether a tag-dispatched method implementation is a default implementation. More...

struct  is_embedded
Returns whether a data type can be embedded into another data type. More...

struct  lazy
hana::lazy implements superficial laziness via a monadic interface. More...

struct  lazy_tag
Tag representing hana::lazy. More...

struct  map
Basic associative container requiring unique, Comparable and Hashable keys. More...

struct  map_tag
Tag representing hana::maps. More...

struct  optional
Optional value whose optional-ness is known at compile-time. More...

struct  optional_tag
Tag representing a hana::optional. More...

struct  pair
Generic container for two elements. More...

struct  pair_tag
Tag representing hana::pair. More...

struct  range
Compile-time half-open interval of hana::integral_constants. More...

struct  range_tag
Tag representing a hana::range. More...

struct  set
Basic unordered container requiring unique, Comparable and Hashable keys. More...

struct  set_tag
Tag representing the hana::set container. More...

struct  string
Compile-time string. More...

struct  string_tag
Tag representing a compile-time string. More...

struct  tag_of
Metafunction returning the tag associated to T. More...

struct  tuple
General purpose index-based heterogeneous sequence with a fixed length. More...

struct  tuple_tag
Tag representing hana::tuples. More...

struct  type
C++ type in value-level representation. More...

struct  type_tag
Tag representing hana::type. More...

struct  when
Enable a partial specialization only if a boolean condition is true. More...

## Typedefs

template<typename T , typename U >
using common_t = typename common< T, U >::type
Alias to common<T, U>::type, provided for convenience. More...

template<typename T >
using tag_of_t = typename hana::tag_of< T >::type
Alias to tag_of<T>::type, provided for convenience. More...

template<typename... >
using when_valid = when< true >
Variant of when allowing specializations to be enabled only if an expression is well-formed. More...

## Functions

Defines a model of Struct with the given accessors.Using this macro at global scope will define a model of the Struct concept for the given type. This can be used to easily adapt existing user-defined types in a ad-hoc manner. Unlike BOOST_HANA_ADAPT_STRUCT, this macro requires specifying the way to retrieve each member by providing a function that does the extraction. More...

Defines a model of Struct with the given members.Using this macro at global scope will define a model of the Struct concept for the given type. This can be used to easily adapt existing user-defined types in a ad-hoc manner. Unlike the BOOST_HANA_DEFINE_STRUCT macro, this macro does not require the types of the members to be specified. More...

auto BOOST_HANA_DEFINE_STRUCT (...)
Defines members of a structure, while at the same time modeling Struct.Using this macro in the body of a user-defined type will define the given members inside that type, and will also provide a model of the Struct concept for that user-defined type. This macro is often the easiest way to define a model of the Struct concept. More...

## Variables

constexpr auto always
Return a constant function returning x regardless of the argument(s) it is invoked with. More...

constexpr auto apply
Invokes a Callable with the given arguments. More...

template<std::size_t n>
constexpr auto arg
Return the nth passed argument. More...

constexpr auto capture
Create a function capturing the given variables. More...

constexpr auto compose
Return the composition of two functions or more. More...

template<std::size_t n>
constexpr auto curry
Curry a function up to the given number of arguments. More...

constexpr auto demux
Invoke a function with the results of invoking other functions on its arguments. More...

constexpr auto fix
Return a function computing the fixed point of a function. More...

constexpr auto flip
Invoke a function with its two first arguments reversed. More...

constexpr auto id
The identity function – returns its argument unchanged. More...

constexpr auto infix
Return an equivalent function that can also be applied in infix notation. More...

template<std::size_t n>
constexpr auto iterate
Applies another function n times to its argument. More...

constexpr auto lockstep
Invoke a function with the result of invoking other functions on its arguments, in lockstep. More...

constexpr auto on
Invoke a function with the result of invoking another function on each argument. More...

Pick one of several functions to call based on overload resolution. More...

Call the first function that produces a valid call expression. More...

constexpr auto partial
Partially apply a function to some arguments. More...

constexpr unspecified _ {}
Create simple functions representing C++ operators inline. More...

constexpr auto reverse_partial
Partially apply a function to some arguments. More...

template<typename S >
constexpr auto accessors
Returns a Sequence of pairs representing the accessors of the data structure.Given a Struct S, accessors<S>() is a Sequence of Products where the first element of each pair is the "name" of a member of the Struct, and the second element of each pair is a function that can be used to access that member when given an object of the proper data type. As described in the global documentation for Struct, the accessor functions in this sequence must be move-independent. More...

Apply a function on all the elements of a structure that compare equal to some value. More...

Apply a function on all the elements of a structure satisfying a predicate.Given a Functor, a predicate pred and a function f, adjust_if will adjust the elements of the Functor that satisfy the predicate with the function f. In other words, adjust_if will return a new Functor equal to the original one, except that the elements satisfying the predicate will be transformed with the given function. Elements for which the predicate is not satisfied are left untouched, and they are kept as-is in the resulting Functor. More...

constexpr auto all
Returns whether all the keys of the structure are true-valued.The keys of the structure must be Logicals. If the structure is not finite, a false-valued key must appear at a finite "index" in order for this method to finish. More...

constexpr auto all_of
Returns whether all the keys of the structure satisfy the predicate.If the structure is not finite, predicate has to return a false- valued Logical after looking at a finite number of keys for this method to finish. More...

constexpr auto and_
Return whether all the arguments are true-valued.and_ can be called with one argument or more. When called with two arguments, and_ uses tag-dispatching to find the right implementation. Otherwise,. More...

constexpr auto any
Returns whether any key of the structure is true-valued.The keys of the structure must be Logicals. If the structure is not finite, a true-valued key must appear at a finite "index" in order for this method to finish. More...

constexpr auto any_of
Returns whether any key of the structure satisfies the predicate.If the structure is not finite, predicate has to be satisfied after looking at a finite number of keys for this method to finish. More...

constexpr auto ap
Lifted application.Specifically, ap applies a structure containing functions to a structure containing values, and returns a new structure containing values. The exact way in which the functions are applied to the values depends on the Applicative. More...

constexpr auto append
Append an element to a monadic structure.Given an element x and a monadic structure xs, append returns a new monadic structure which is the result of lifting x into the monadic structure and then combining that (to the right) with xs. In other words,. More...

constexpr auto at
Returns the nth element of an iterable.Given an Iterable and an IntegralConstant index, at returns the element located at the index in the linearization of the iterable. Specifically, given an iterable xs with a linearization of [x1, ..., xN], at(xs, k) is equivalent to xk. More...

template<std::size_t n>
constexpr auto at_c
Equivalent to at; provided for convenience. More...

constexpr auto at_key
Returns the value associated to the given key in a structure, or fail.Given a key and a Searchable structure, at_key returns the first value whose key is equal to the given key, and fails at compile-time if no such key exists. This requires the key to be compile-time Comparable, exactly like for find. at_key satisfies the following: More...

constexpr auto back
Returns the last element of a non-empty and finite iterable.Given a non-empty and finite iterable xs with a linearization of [x1, ..., xN], back(xs) is equal to xN. Equivalently, back(xs) must be equivalent to at_c<N-1>(xs), and that regardless of the value category of xs (back must respect the reference semantics of at). More...

constexpr auto cartesian_product
Computes the cartesian product of a sequence of sequences.Given a sequence of sequences, cartesian_product returns a new sequence of sequences containing the cartesian product of the original sequences. For this method to finish, a finite number of finite sequences must be provided. More...

constexpr auto chain
Feed a monadic value into a monadic computation.Given a monadic value and a monadic function, chain feeds the monadic value into the function, thus performing some Monad-specific effects, and returns the result. An implementation of chain must satisfy. More...

constexpr auto comparing
Returns a function performing equal after applying a transformation to both arguments.comparing creates an equivalence relation based on the result of applying a function to some objects, which is especially useful in conjunction with algorithms that accept a custom predicate that must represent an equivalence relation. More...

constexpr auto concat
Combine two monadic structures together.Given two monadic structures, concat combines them together and returns a new monadic structure. The exact definition of concat will depend on the exact model of MonadPlus at hand, but for sequences it corresponds intuitively to simple concatenation. More...

constexpr auto contains
Returns whether the key occurs in the structure.Given a Searchable structure xs and a key, contains returns whether any of the keys of the structure is equal to the given key. If the structure is not finite, an equal key has to appear at a finite position in the structure for this method to finish. For convenience, contains can also be applied in infix notation. More...

constexpr auto in = hana::infix(hana::flip(hana::contains))
Return whether the key occurs in the structure.Specifically, this is equivalent to contains, except in takes its arguments in reverse order. Like contains, in can also be applied in infix notation for increased expressiveness. This function is not a method that can be overriden; it is just a convenience function provided with the concept. More...

template<typename Tag , typename optional_T >
constexpr auto is_a = see-documentation
Returns whether the tag of an object matches a given tag. More...

template<typename Tag , typename... T>
constexpr auto is_an = is_a<Tag, T...>
Equivalent to is_a; provided for consistency with the rules of the English language.

template<typename Tag >
constexpr auto make
Create an object of the given tag with the given arguments. More...

template<typename To >
constexpr auto to
Converts an object from one data type to another. More...

constexpr auto count
Return the number of elements in the structure that compare equal to a given value.Given a Foldable structure xs and a value value, count returns an unsigned integral, or a Constant thereof, representing the number of elements of xs that compare equal to value. For this method to be well-defined, all the elements of the structure must be Comparable with the given value. More...

constexpr auto count_if
Return the number of elements in the structure for which the predicate is satisfied.Specifically, returns an object of an unsigned integral type, or a Constant holding such an object, which represents the number of elements in the structure satisfying the given predicate. More...

constexpr auto cycle
Combine a monadic structure with itself n times.Given a monadic structure xs and a non-negative number n, cycle returns a new monadic structure which is the result of combining xs with itself n times using the concat operation. In other words,. More...

constexpr auto div
Generalized integer division. More...

constexpr auto drop_back
Drop the last n elements of a finite sequence, and return the rest.Given a finite Sequence xs with a linearization of [x1, ..., xm] and a non-negative IntegralConstant n, drop_back(xs, n) is a sequence with the same tag as xs whose linearization is [x1, ..., xm-n]. If n is not given, it defaults to an IntegralConstant with a value equal to 1. More...

constexpr auto drop_front
Drop the first n elements of an iterable, and return the rest.Given an Iterable xs with a linearization of [x1, x2, ...] and a non-negative IntegralConstant n, drop_front(xs, n) is an iterable with the same tag as xs whose linearization is [xn+1, xn+2, ...]. In particular, note that this function does not mutate the original iterable in any way. If n is not given, it defaults to an IntegralConstant with a value equal to 1. More...

constexpr auto drop_front_exactly
Drop the first n elements of an iterable, and return the rest.Given an Iterable xs with a linearization of [x1, x2, ...] and a non-negative IntegralConstant n, drop_front_exactly(xs, n) is an iterable with the same tag as xs whose linearization is [xn+1, xn+2, ...]. In particular, note that this function does not mutate the original iterable in any way. If n is not given, it defaults to an IntegralConstant with a value equal to 1. More...

constexpr auto drop_while
Drop elements from an iterable up to, but excluding, the first element for which the predicate is not satisfied.Specifically, drop_while returns an iterable containing all the elements of the original iterable except for those in the range delimited by [head, e), where head is the first element and e is the first element for which the predicate is not satisfied. If the iterable is not finite, the predicate has to return a false- valued Logical at a finite index for this method to return. More...

constexpr auto duplicate
Add an extra layer of comonadic context to a comonadic value.Given a value already in a comonadic context, duplicate wraps this value with an additional layer of comonadic context. This can be seen as the dual operation to flatten from the Monad concept. More...

template<typename M >
constexpr auto empty
Identity of the monadic combination concat.

## Signature

Given a MonadPlus M, the signature is $$\mathtt{empty}_M : \emptyset \to M(T)$$. More...

constexpr auto equal
Returns a Logical representing whether x is equal to y.The equal function can be called in two different ways. First, it can be called like a normal function: More...

constexpr auto eval_if
Conditionally execute one of two branches based on a condition.Given a condition and two branches in the form of lambdas or hana::lazys, eval_if will evaluate the branch selected by the condition with eval and return the result. The exact requirements for what the branches may be are the same requirements as those for the eval function. More...

constexpr auto extend
Comonadic application of a function to a comonadic value.Given a comonadic value and a function accepting a comonadic input, extend returns the result of applying the function to that input inside the comonadic context. More...

constexpr auto extract
Extract a value in a given comonadic context.Given a value inside a comonadic context, extract it from that context, performing whatever effects are mandated by that context. This can be seen as the dual operation to the lift method of the Applicative concept. More...

constexpr auto fill
Replace all the elements of a structure with a fixed value. More...

constexpr auto filter
Filter a monadic structure using a custom predicate.Given a monadic structure and a predicate, filter returns a new monadic structure containing only those elements that satisfy the predicate. This is a generalization of the usual filter function for sequences; it works for any MonadPlus. Intuitively, filter is somewhat equivalent to: More...

constexpr auto find
Finds the value associated to the given key in a structure.Given a key and a Searchable structure, find returns the just the first value whose key is equal to the given key, or nothing if there is no such key. Comparison is done with equal. find satisfies the following: More...

constexpr auto find_if
Finds the value associated to the first key satisfying a predicate.Given a Searchable structure xs and a predicate pred, find_if(xs, pred) returns just the first element whose key satisfies the predicate, or nothing if there is no such element. More...

constexpr auto first
Returns the first element of a pair.Note that if the Product actually stores the elements it contains, hana::first is required to return a lvalue reference, a lvalue reference to const or a rvalue reference to the first element, where the type of reference must match that of the pair passed to first. If the Product does not store the elements it contains (i.e. it generates them on demand), this requirement is dropped. More...

constexpr auto flatten
Collapse two levels of monadic structure into a single level.Given a monadic value wrapped into two levels of monad, flatten removes one such level. An implementation of flatten must satisfy. More...

constexpr auto fold = fold_left
Equivalent to fold_left; provided for convenience.fold is equivalent to fold_left. However, it is not tag-dispatched on its own because it is just an alias to fold_left. Also note that fold can be called with or without an initial state, just like fold_left: More...

constexpr auto fold_left
Left-fold of a structure using a binary operation and an optional initial reduction state.fold_left is a left-associative fold using a binary operation. Given a structure containing x1, ..., xn, a function f and an optional initial state, fold_left applies f as follows. More...

constexpr auto fold_right
Right-fold of a structure using a binary operation and an optional initial reduction state.fold_right is a right-associative fold using a binary operation. Given a structure containing x1, ..., xn, a function f and an optional initial state, fold_right applies f as follows. More...

constexpr auto for_each
Perform an action on each element of a foldable, discarding the result each time.Iteration is done from left to right, i.e. in the same order as when using fold_left. If the structure is not finite, this method will not terminate. More...

constexpr auto front
Returns the first element of a non-empty iterable.Given a non-empty Iterable xs with a linearization of [x1, ..., xN], front(xs) is equal to x1. If xs is empty, it is an error to use this function. Equivalently, front(xs) must be equivalent to at_c<0>(xs), and that regardless of the value category of xs (front must respect the reference semantics of at). More...

constexpr auto fuse
Transform a function taking multiple arguments into a function that can be called with a compile-time Foldable. More...

constexpr auto greater
Returns a Logical representing whether x is greater than y. More...

constexpr auto greater_equal
Returns a Logical representing whether x is greater than or equal to y. More...

constexpr auto group
Group adjacent elements of a sequence that all respect a binary predicate, by default equality.Given a finite Sequence and an optional predicate (by default equal), group returns a sequence of subsequences representing groups of adjacent elements that are "equal" with respect to the predicate. In other words, the groups are such that the predicate is satisfied when it is applied to any two adjacent elements in that group. The sequence returned by group is such that the concatenation of its elements is equal to the original sequence, which is equivalent to saying that the order of the elements is not changed. More...

constexpr auto hash
Returns a hana::type representing the compile-time hash of an object.Given an arbitrary object x, hana::hash returns a hana::type representing the hash of x. In normal programming, hashes are usually numerical values that can be used e.g. as indices in an array as part of the implementation of a hash table. In the context of metaprogramming, we are interested in type-level hashes instead. Thus, hana::hash must return a hana::type object instead of an integer. This hana::type must somehow summarize the object being hashed, but that summary may of course lose some information. More...

constexpr auto if_
Conditionally return one of two values based on a condition.Specifically, then is returned iff cond is true-valued, and else_ is returned otherwise. Note that some Logical models may allow then and else_ to have different types, while others may require both values to have the same type. More...

constexpr insert_t insert {}
Insert a value at a given index in a sequence.Given a sequence, an index and an element to insert, insert inserts the element at the given index. More...

constexpr auto insert_range
Insert several values at a given index in a sequence.Given a sequence, an index and any Foldable containing elements to insert, insert_range inserts the elements in the Foldable at the given index of the sequence. More...

constexpr auto intersperse
Insert a value between each pair of elements in a finite sequence.Given a finite Sequence xs with a linearization of [x1, x2, ..., xn], intersperse(xs, z) is a new sequence with a linearization of [x1, z, x2, z, x3, ..., xn-1, z, xn]. In other words, it inserts the z element between every pair of elements of the original sequence. If the sequence is empty or has a single element, intersperse returns the sequence as-is. In all cases, the sequence must be finite. More...

constexpr auto is_disjoint
Returns whether two Searchables are disjoint.Given two Searchables xs and ys, is_disjoint returns a Logical representing whether the keys in xs are disjoint from the keys in ys, i.e. whether both structures have no keys in common. More...

constexpr auto is_empty
Returns whether the iterable is empty.Given an Iterable xs, is_empty returns whether xs contains no more elements. In other words, it returns whether trying to extract the tail of xs would be an error. In the current version of the library, is_empty must return an IntegralConstant holding a value convertible to bool. This is because only compile-time Iterables are supported right now. More...

constexpr auto is_subset
Returns whether a structure contains a subset of the keys of another structure.Given two Searchables xs and ys, is_subset returns a Logical representing whether xs is a subset of ys. In other words, it returns whether all the keys of xs are also present in ys. This method does not return whether xs is a strict subset of ys; if xs and ys are equal, all the keys of xs are also present in ys, and is_subset returns true. More...

constexpr keys_t keys {}
Returns a Sequence containing the name of the members of the data structure.Given a Struct object, keys returns a Sequence containing the name of all the members of the Struct, in the same order as they appear in the accessors sequence. More...

constexpr auto length
Return the number of elements in a foldable structure.Given a Foldable xs, length(xs) must return an object of an unsigned integral type, or an IntegralConstant holding such an object, which represents the number of elements in the structure. More...

constexpr auto less
Returns a Logical representing whether x is less than y. More...

constexpr auto less_equal
Returns a Logical representing whether x is less than or equal to y. More...

constexpr auto lexicographical_compare
Short-circuiting lexicographical comparison of two Iterables with an optional custom predicate, by default hana::less.Given two Iterables xs and ys and a binary predicate pred, lexicographical_compare returns whether xs is to be considered less than ys in a lexicographical ordering. Specifically, let's denote the linearizations of xs and ys by [x1, x2, ...] and [y1, y2, ...], respectively. If the first couple satisfying the predicate is of the form xi, yi, lexicographical_compare returns true. Otherwise, if the first couple to satisfy the predicate is of the form yi, xi, lexicographical_compare returns false. If no such couple can be found, lexicographical_compare returns whether xs has fewer elements than ys. More...

template<typename A >
constexpr auto lift
Lift a value into an Applicative structure.lift<A> takes a normal value and embeds it into a structure whose shape is represented by the A Applicative. Note that the value may be a function, in which case the created structure may be applied to another Applicative structure containing values. More...

constexpr auto max
Returns the greatest of its arguments according to the less ordering. More...

constexpr auto maximum
Return the greatest element of a non-empty structure with respect to a predicate, by default less.Given a non-empty structure and an optional binary predicate (less by default), maximum returns the greatest element of the structure, i.e. an element which is greater than or equal to every other element in the structure, according to the predicate. More...

constexpr auto members
Returns a Sequence containing the members of a Struct.Given a Struct object, members returns a Sequence containing all the members of the Struct, in the same order as their respective accessor appears in the accessors sequence. More...

constexpr auto min
Returns the smallest of its arguments according to the less ordering. More...

constexpr auto minimum
Return the least element of a non-empty structure with respect to a predicate, by default less.Given a non-empty structure and an optional binary predicate (less by default), minimum returns the least element of the structure, i.e. an element which is less than or equal to every other element in the structure, according to the predicate. More...

constexpr auto minus
Subtract two elements of a group.Specifically, this performs the Monoid operation on the first argument and on the inverse of the second argument, thus being equivalent to: More...

constexpr auto mod
Generalized integer modulus.Given two elements of an EuclideanRing x and y, with y nonzero, mod returns the modulus of the division of x by y. In other words, mod can be seen as an equivalent to %. More...

Composition of monadic functions.Given two monadic functions f and g, monadic_compose returns a new function equivalent to the composition of f with g, except the result of g is chained into f instead of simply passed to it, as with normal composition. monadic_compose satisfies. More...

template<typename M >
Monadic left-fold of a structure with a binary operation and an optional initial reduction state. More...

template<typename M >
Monadic right-fold of a structure with a binary operation and an optional initial reduction state. More...

constexpr auto mult
Associative operation of a Ring. More...

constexpr auto negate
Return the inverse of an element of a group. More...

constexpr auto none
Returns whether all of the keys of the structure are false-valued.The keys of the structure must be Logicals. If the structure is not finite, a true-valued key must appear at a finite "index" in order for this method to finish. More...

constexpr auto none_of
Returns whether none of the keys of the structure satisfy the predicate.If the structure is not finite, predicate has to return a true- valued Logical after looking at a finite number of keys for this method to finish. More...

constexpr auto not_
Negates a Logical.This method returns a Logical with the same tag, but whose truth-value is negated. Specifically, not_(x) returns a false-valued Logical if x is a true-valued Logical, and a true-valued one otherwise. More...

constexpr auto not_equal
Returns a Logical representing whether x is not equal to y.The not_equal function can be called in two different ways. First, it can be called like a normal function: More...

template<typename R >
constexpr auto one
Identity of the Ring multiplication. More...

constexpr auto or_
Return whether any of the arguments is true-valued.or_ can be called with one argument or more. When called with two arguments, or_ uses tag-dispatching to find the right implementation. Otherwise,. More...

constexpr auto ordering
Returns a function performing less after applying a transformation to both arguments.ordering creates a total order based on the result of applying a function to some objects, which is especially useful in conjunction with algorithms that accept a custom predicate that must represent a total order. More...

constexpr auto partition
Partition a sequence based on a predicate.Specifically, returns an unspecified Product whose first element is a sequence of the elements satisfying the predicate, and whose second element is a sequence of the elements that do not satisfy the predicate. More...

constexpr auto permutations
Return a sequence of all the permutations of the given sequence.Specifically, permutations(xs) is a sequence whose elements are permutations of the original sequence xs. The permutations are not guaranteed to be in any specific order. Also note that the number of permutations grows very rapidly as the length of the original sequence increases. The growth rate is O(length(xs)!); with a sequence xs of length only 8, permutations(xs) contains over 40 000 elements! More...

constexpr auto plus
Associative binary operation on a Monoid. More...

constexpr auto power
Elevate a ring element to its nth power.Specifically, power(x, n), is equivalent to multiplying x with itself n times using the Ring's multiplication. If the power is equal to zero, the Ring's identity (one) is returned. More...

constexpr auto prefix
Inserts a value before each element of a monadic structure.Given a monadic structure xs and a value z called the prefix, prefix returns a new monadic structure. prefix satisfies. More...

constexpr auto prepend
Prepend an element to a monadic structure.Given a monadic structure xs and an element x, prepend returns a new monadic structure which is the result of lifting x into the monadic structure and then combining that (to the left) with xs. In other words,. More...

constexpr auto product = see documentation
Compute the product of the numbers of a structure.More generally, product will take any foldable structure containing objects forming a Ring and reduce them using the Ring's binary operation. The initial state for folding is the identity of the Ring's operation. It is sometimes necessary to specify the Ring to use; this is possible by using product<R>. If no Ring is specified, the structure will use the Ring formed by the elements it contains (if it knows it), or integral_constant_tag<int> otherwise. Hence,. More...

constexpr auto remove
Remove all the elements of a monadic structure that are equal to some value.Given a monadic structure xs and a value, remove returns a new monadic structure equal to xs without all its elements that are equal to the given value. remove is equivalent to remove_if with the equal.to(value) predicate, i.e. More...

constexpr auto remove_at
Remove the element at a given index from a sequence.remove_at returns a new sequence identical to the original, except that the element at the given index is removed. Specifically, remove_at([x0, ..., xn-1, xn, xn+1, ..., xm], n) is a new sequence equivalent to [x0, ..., xn-1, xn+1, ..., xm]. More...

template<std::size_t n>
constexpr auto remove_at_c
Equivalent to remove_at; provided for convenience. More...

constexpr auto remove_if
Remove all the elements of a monadic structure that satisfy some predicate.Given a monadic structure xs and a unary predicate, remove_if returns a new monadic structure equal to xs without all its elements that satisfy the predicate. This is equivalent to filter with a negated predicate, i.e. More...

constexpr auto remove_range
Remove the elements inside a given range of indices from a sequence.remove_range returns a new sequence identical to the original, except that elements at indices in the provided range are removed. Specifically, remove_range([x0, ..., xn], from, to) is a new sequence equivalent to [x0, ..., x_from-1, x_to, ..., xn]. More...

template<std::size_t from, std::size_t to>
constexpr auto remove_range_c
Equivalent to remove_range; provided for convenience. More...

constexpr auto repeat
Invokes a nullary function n times.Given an IntegralConstant n and a nullary function f, repeat(n, f) will call f n times. In particular, any decent compiler should expand repeat(n, f) to. More...

constexpr auto replace
Replace all the elements of a structure that compare equal to some value with some new fixed value. More...

constexpr auto replace_if
Replace all the elements of a structure satisfying a predicate with a fixed value. More...

template<typename M >
constexpr auto replicate
Create a monadic structure by combining a lifted value with itself n times.Given a value x, a non-negative IntegralConstant n and the tag of a monadic structure M, replicate creates a new monadic structure which is the result of combining x with itself n times inside the monadic structure. In other words, replicate simply lifts x into the monadic structure, and then combines that with itself n times: More...

constexpr auto reverse
Reverse a sequence.Specifically, reverse(xs) is a new sequence containing the same elements as xs, except in reverse order. More...

constexpr auto reverse_fold
Equivalent to reverse_fold in Boost.Fusion and Boost.MPL.This method has the same semantics as reverse_fold in Boost.Fusion and Boost.MPL, with the extension that an initial state is not required. This method is equivalent to fold_right, except that the accumulating function must take its arguments in reverse order, to match the order used in Fusion. In other words,. More...

constexpr auto scan_left
Fold a Sequence to the left and return a list containing the successive reduction states.Like fold_left, scan_left reduces a sequence to a single value using a binary operation. However, unlike fold_left, it builds up a sequence of the intermediary results computed along the way and returns that instead of only the final reduction state. Like fold_left, scan_left can be used with or without an initial reduction state. More...

constexpr auto scan_right
Fold a Sequence to the right and return a list containing the successive reduction states.Like fold_right, scan_right reduces a sequence to a single value using a binary operation. However, unlike fold_right, it builds up a sequence of the intermediary results computed along the way and returns that instead of only the final reduction state. Like fold_right, scan_right can be used with or without an initial reduction state. More...

constexpr auto second
Returns the second element of a pair.Note that if the Product actually stores the elements it contains, hana::second is required to return a lvalue reference, a lvalue reference to const or a rvalue reference to the second element, where the type of reference must match that of the pair passed to second. If the Product does not store the elements it contains (i.e. it generates them on demand), this requirement is dropped. More...

constexpr auto size = hana::length
Equivalent to length; provided for consistency with the standard library.This method is an alias to length provided for convenience and consistency with the standard library. As an alias, size is not tag-dispatched on its own and length should be customized instead. More...

constexpr auto slice
Extract the elements of a Sequence at the given indices.Given an arbitrary sequence of indices, slice returns a new sequence of the elements of the original sequence that appear at those indices. In other words,. More...

template<std::size_t from, std::size_t to>
constexpr auto slice_c
Shorthand to slice a contiguous range of elements.slice_c is simply a shorthand to slice a contiguous range of elements. In particular, slice_c<from, to>(xs) is equivalent to slice(xs, range_c<std::size_t, from, to>), which simply slices all the elements of xs contained in the half-open interval delimited by [from, to). Like for slice, the indices used with slice_c are 0-based and they must be in the bounds of the sequence being sliced. More...

constexpr auto sort
Sort a sequence, optionally based on a custom predicate.Given a Sequence and an optional predicate (by default less), sort returns a new sequence containing the same elements as the original, except they are ordered in such a way that if x comes before y in the sequence, then either predicate(x, y) is true, or both predicate(x, y) and predicate(y, x) are false. More...

constexpr auto span
Returns a Product containing the longest prefix of a sequence satisfying a predicate, and the rest of the sequence.The first component of the returned Product is a sequence for which all elements satisfy the given predicate. The second component of the returned Product is a sequence containing the remainder of the argument. Both or either sequences may be empty, depending on the input argument. More specifically,. More...

constexpr auto suffix
Inserts a value after each element of a monadic structure.Given a monadic structure xs and a value z (called the suffix), suffix returns a new monadic structure such that. More...

constexpr auto sum = see documentation
Compute the sum of the numbers of a structure.More generally, sum will take any foldable structure containing objects forming a Monoid and reduce them using the Monoid's binary operation. The initial state for folding is the identity of the Monoid. It is sometimes necessary to specify the Monoid to use; this is possible by using sum<M>. If no Monoid is specified, the structure will use the Monoid formed by the elements it contains (if it knows it), or integral_constant_tag<int> otherwise. Hence,. More...

constexpr auto take_back
Returns the last n elements of a sequence, or the whole sequence if the sequence has less than n elements.Given a Sequence xs and an IntegralConstant n, take_back(xs, n) is a new sequence containing the last n elements of xs, in the same order. If length(xs) <= n, the whole sequence is returned and no error is triggered. More...

constexpr auto take_front
Returns the first n elements of a sequence, or the whole sequence if the sequence has less than n elements.Given a Sequence xs and an IntegralConstant n, take_front(xs, n) is a new sequence containing the first n elements of xs, in the same order. If length(xs) <= n, the whole sequence is returned and no error is triggered. More...

template<std::size_t n>
constexpr auto take_front_c
Equivalent to take_front; provided for convenience. More...

constexpr auto take_while
Take elements from a sequence while the predicate is satisfied.Specifically, take_while returns a new sequence containing the longest prefix of xs in which all the elements satisfy the given predicate. More...

template<typename M >
constexpr auto tap
Tap inside a monadic chain.Given a function f, tap<M> returns a new function which performs f on its argument and then returns the argument lifted in the M Monad. Combined with the property that chain(m, lift<M>) == m, this provides a way of executing an action inside a monadic chain without influencing its overall result. This is useful to e.g. insert debug statements or perform actions that are not tied to the chain but that need to be executed inside of it. More...

constexpr auto then
Sequentially compose two monadic actions, discarding any value produced by the first but not its effects. More...

constexpr auto transform
Map a function over a Functor. More...

template<template< typename... > class F>
constexpr auto template_
Lift a template to a Metafunction.Given a template class or template alias f, template_<f> is a Metafunction satisfying. More...

template<template< typename... > class F>
constexpr auto metafunction
Lift a MPL-style metafunction to a Metafunction.Given a MPL-style metafunction, metafunction<f> is a Metafunction satisfying. More...

template<typename F >
constexpr auto metafunction_class
Lift a MPL-style metafunction class to a Metafunction.Given a MPL-style metafunction class, metafunction_class<f> is a Metafunction satisfying. More...

constexpr auto integral
Turn a Metafunction into a function taking types and returning a default-constructed object.Given a Metafunction f, integral returns a new Metafunction that default-constructs an object of the type returned by f. More specifically, the following holds: More...

template<template< typename... > class F>
constexpr auto trait = hana::integral(hana::metafunction<F>)
Alias to integral(metafunction<F>), provided for convenience. More...

template<typename S >
constexpr auto unfold_left
Dual operation to fold_left for sequences.While fold_left reduces a structure to a summary value from the left, unfold_left builds a sequence from a seed value and a function, starting from the left. More...

template<typename S >
constexpr auto unfold_right
Dual operation to fold_right for sequences.While fold_right reduces a structure to a summary value from the right, unfold_right builds a sequence from a seed value and a function, starting from the right. More...

constexpr auto unique
Removes all consecutive duplicate elements from a Sequence.Given a Sequence and an optional binary predicate, unique returns a new sequence containing only the first element of every subrange of the original sequence whose elements are all equal. In other words, it turns a sequence of the form [a, a, b, c, c, c, d, d, d, a] into a sequence [a, b, c, d, a]. The equality of two elements is determined by the provided predicate, or by equal if no predicate is provided. More...

constexpr auto unpack
Invoke a function with the elements of a Foldable as arguments.Given a function and a foldable structure whose length can be known at compile-time, unpack invokes the function with the contents of that structure. In other words, unpack(xs, f) is equivalent to f(x...), where x... are the elements of the structure. The length of the structure must be known at compile-time, because the version of f's operator() that will be compiled depends on the number of arguments it is called with, which has to be known at compile-time. More...

template<typename T >
constexpr auto value
Return the compile-time value associated to a constant.This function returns the value associated to a Constant. That value is always a constant expression. The normal way of using value on an object c is. More...

constexpr auto value_of
Equivalent to value, but can be passed to higher-order algorithms.This function object is equivalent to value, except it can be passed to higher order algorithms because it is a function object. value can't be passed to higher-order algorithms because it is implemented as an overloaded function. More...

constexpr auto while_
Apply a function to an initial state while some predicate is satisfied.This method is a natural extension of the while language construct to manipulate a state whose type may change from one iteration to another. However, note that having a state whose type changes from one iteration to the other is only possible as long as the predicate returns a Logical whose truth value is known at compile-time. More...

template<typename M >
constexpr auto zero
Identity of plus. More...

constexpr auto zip
Zip one sequence or more.Given n sequences s1, ..., sn, zip produces a sequence whose i-th element is a tuple of (s1[i], ..., sn[i]), where sk[i] denotes the i-th element of the k-th sequence. In other words, zip produces a sequence of the form. More...

constexpr auto zip_shortest
Zip one sequence or more.Given n sequences s1, ..., sn, zip_shortest produces a sequence whose i-th element is a tuple of (s1[i], ..., sn[i]), where sk[i] denotes the i-th element of the k-th sequence. In other words, zip_shortest produces a sequence of the form. More...

constexpr auto zip_shortest_with
Zip one sequence or more with a given function.Given a n-ary function f and n sequences s1, ..., sn, zip_shortest_with produces a sequence whose i-th element is f(s1[i], ..., sn[i]), where sk[i] denotes the i-th element of the k-th sequence. In other words, zip_shortest_with produces a sequence of the form. More...

constexpr auto zip_with
Zip one sequence or more with a given function.Given a n-ary function f and n sequences s1, ..., sn, zip_with produces a sequence whose i-th element is f(s1[i], ..., sn[i]), where sk[i] denotes the i-th element of the k-th sequence. In other words, zip_with produces a sequence of the form. More...

## Detailed Description

Namespace containing everything in the library.

## Variable Documentation

 constexpr auto boost::hana::repeat
Initial value:
= [](auto const& n, auto&& f) -> void {
f(); f(); ... f();
}

Invokes a nullary function n times.Given an IntegralConstant n and a nullary function f, repeat(n, f) will call f n times. In particular, any decent compiler should expand repeat(n, f) to.

f(); f(); ... f(); // n times total
Parameters
 n An IntegralConstant holding a non-negative value representing the number of times f should be repeatedly invoked. f A function to repeatedly invoke n times. f is allowed to have side effects.