Boost.Hana: boost::hana Namespace Reference

| Boost.Hana 1.7.1 Your standard library for metaprogramming |

Namespaces | Classes | Typedefs | Functions | Variables
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 | has_common
| Metafunction returning whether two data types share a common data type. More...
struct | is_default
| Returns whether a tag-dispatched method implementation is a default implementation. More...
struct | is_convertible
| Returns whether there is a Hana-conversion from a data type to another. More...
struct | is_embedded
| Returns whether a data type can be embedded into another data type. More...
struct | integral_constant_tag
| Tag representing `hana::integral_constant`. More...
struct | integral_constant
| Compile-time value of an integral type. More...
struct | basic_tuple
| Stripped down version of `hana::tuple`. More...
struct | basic_tuple_tag
| Tag representing `hana::basic_tuple`. More...
struct | IntegralConstant
| The `IntegralConstant` concept represents compile-time integral values. 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 | tag_of
| Metafunction returning the tag associated to `T`. More...
struct | embedding
| Marks a conversion between data types as being an embedding. More...
struct | when
| Enable a partial specialization only if a boolean condition is true. More...
struct | lazy
| `hana::lazy` implements superficial laziness via a monadic interface. More...
struct | lazy_tag
| Tag representing `hana::lazy`. More...
struct | map_tag
| Tag representing `hana::map`s. More...
struct | map
| Basic associative container requiring unique, `Comparable` and `Hashable` keys. 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_constant`s. 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 | tuple
| General purpose index-based heterogeneous sequence with a fixed length. More...
struct | tuple_tag
| Tag representing `hana::tuple`s. More...
struct | basic_type
| Base class of `hana::type`; used for pattern-matching. More...
struct | type
| C++ type in value-level representation. More...
struct | type_tag
| Tag representing `hana::type`. 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
auto | BOOST_HANA_ADAPT_ADT (...)
| Defines a model of `Struct` with the given accessors. More...
auto | BOOST_HANA_ADAPT_STRUCT (...)
| Defines a model of `Struct` with the given members. More...
times | A (T_1) \times \cdots \times A(T_n) \to A(U) @f$. const expr auto ap
| Lifted application. More...
auto | BOOST_HANA_DEFINE_STRUCT (...)
| Defines members of a structure, while at the same time modeling `Struct`. 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 `n`th 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...
| mathtt
| 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...
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...
constexpr auto | overload
| Pick one of several functions to call based on overload resolution. More...
constexpr auto | overload_linearly
| 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. More...
constexpr auto | all
| Returns whether all the keys of the structure are true-valued. More...
constexpr auto | all_of
| Returns whether all the keys of the structure satisfy the `predicate`. More...
constexpr auto | and_
| Return whether all the arguments are true-valued. More...
constexpr auto | any
| Returns whether any key of the structure is true-valued. More...
constexpr auto | any_of
| Returns whether any key of the structure satisfies the `predicate`. More...
constexpr auto | append
| Append an element to a monadic structure. More...
constexpr auto | at
| Returns the `n`th element of an iterable. 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. More...
constexpr auto | back
| Returns the last element of a non-empty and finite iterable. More...
constexpr auto | comparing
| Returns a function performing `equal` after applying a transformation to both arguments. More...
constexpr auto | concat
| Combine two monadic structures together. More...
constexpr auto | contains
| Returns whether the key occurs in the structure. More...
constexpr auto | in = hana::infix(hana::flip(hana::contains))
| Return whether the key occurs in the structure. 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. More...
constexpr auto | count_if
| Return the number of elements in the structure for which the `predicate` is satisfied. More...
constexpr auto | cycle
| Combine a monadic structure with itself `n` times. 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. More...
constexpr auto | drop_front
| Drop the first `n` elements of an iterable, and return the rest. More...
constexpr auto | drop_front_exactly
| Drop the first `n` elements of an iterable, and return the rest. More...
constexpr auto | drop_while
| Drop elements from an iterable up to, but excluding, the first element for which the `predicate` is not satisfied. More...
template<typename M >
constexpr auto | empty
| Identity of the monadic combination `concat`. More...
constexpr auto | equal
| Returns a `Logical` representing whether `x` is equal to `y`. More...
constexpr auto | eval_if
| Conditionally execute one of two branches based on a condition. More...
constexpr auto | filter
| Filter a monadic structure using a custom predicate. More...
constexpr auto | find
| Finds the value associated to the given key in a structure. More...
constexpr auto | find_if
| Finds the value associated to the first key satisfying a predicate. More...
constexpr auto | first
| Returns the first element of a pair. More...
constexpr auto | fold = fold_left
| Equivalent to `fold_left`; provided for convenience. More...
constexpr auto | for_each
| Perform an action on each element of a foldable, discarding the result each time. More...
constexpr auto | front
| Returns the first element of a non-empty iterable. 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 | if_
| Conditionally return one of two values based on a condition. More...
constexpr auto | index_if
| Finds the value associated to the first key satisfying a predicate. More...
constexpr insert_t | insert {}
| Insert a value at a given index in a sequence. More...
constexpr auto | insert_range
| Insert several values at a given index in a sequence. More...
constexpr auto | intersperse
| Insert a value between each pair of elements in a finite sequence. More...
constexpr auto | is_disjoint
| Returns whether two `Searchable`s are disjoint. More...
constexpr auto | is_empty
| Returns whether the iterable is empty. More...
constexpr auto | is_subset
| Returns whether a structure contains a subset of the keys of another structure. More...
constexpr keys_t | keys {}
| Returns a `Sequence` containing the name of the members of the data structure. More...
constexpr auto | length
| Return the number of elements in a foldable 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...
template<typename A >
constexpr auto | lift
| Lift a value into an `Applicative` structure. More...
constexpr auto | max
| Returns the greatest of its arguments according to the `less` ordering. More...
constexpr auto | members
| Returns a `Sequence` containing the members of a `Struct`. More...
constexpr auto | min
| Returns the smallest of its arguments according to the `less` ordering. More...
constexpr auto | minus
| Subtract two elements of a group. More...
constexpr auto | mod
| Generalized integer modulus. 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. More...
constexpr auto | none_of
| Returns whether none of the keys of the structure satisfy the `predicate`. More...
constexpr auto | not_
| Negates a `Logical`. More...
constexpr auto | not_equal
| Returns a `Logical` representing whether `x` is not equal to `y`. 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. More...
constexpr auto | ordering
| Returns a function performing `less` after applying a transformation to both arguments. More...
constexpr auto | permutations
| Return a sequence of all the permutations of the given sequence. More...
constexpr auto | plus
| Associative binary operation on a `Monoid`. More...
constexpr auto | power
| Elevate a ring element to its `n`th power. More...
constexpr auto | prefix
| Inserts a value before each element of a monadic structure. More...
constexpr auto | prepend
| Prepend an element to a monadic structure. More...
constexpr auto | product = see documentation
| Compute the product of the numbers of a structure. More...
| mathrm
| Remove all the elements of a monadic structure that are equal to some value. More...
constexpr auto | remove_at
| Remove the element at a given index from a sequence. More...
template<std::size_t n>
constexpr auto | remove_at_c
| Equivalent to `remove_at`; provided for convenience. More...
constexpr auto | remove_range
| Remove the elements inside a given range of indices from a sequence. 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. More...
template<typename M >
constexpr auto | replicate
| Create a monadic structure by combining a lifted value with itself `n` times. More...
constexpr auto | reverse
| Reverse a sequence. More...
constexpr auto | scan_left
| Fold a Sequence to the left and return a list containing the successive reduction states. More...
constexpr auto | scan_right
| Fold a Sequence to the right and return a list containing the successive reduction states. More...
constexpr auto | second
| Returns the second element of a pair. More...
constexpr auto | size = hana::length
| Equivalent to `length`; provided for consistency with the standard library. More...
constexpr auto | slice
| Extract the elements of a `Sequence` at the given indices. More...
template<std::size_t from, std::size_t to>
constexpr auto | slice_c
| Shorthand to `slice` a contiguous range of elements. More...
constexpr auto | suffix
| Inserts a value after each element of a monadic structure. More...
constexpr auto | sum = see documentation
| Compute the sum of the numbers of a structure. 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. More...
template<std::size_t n>
constexpr auto | take_back_c
| Equivalent to `take_back`; provided for convenience. 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. 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. More...
template<typename M >
constexpr auto | tap
| Tap inside a monadic chain. More...
constexpr auto | then
| Sequentially compose two monadic actions, discarding any value produced by the first but not its effects. More...
template<template< typename ... > class F>
constexpr auto | template_
| Lift a template to a Metafunction. More...
template<template< typename ... > class F>
constexpr auto | metafunction
| Lift a MPL-style metafunction to a Metafunction. More...
template<typename F >
constexpr auto | metafunction_class
| Lift a MPL-style metafunction class to a Metafunction. More...
constexpr auto | integral
| Turn a `Metafunction` into a function taking `type`s and returning a default-constructed object. More...
template<template< typename ... > class F>
constexpr auto | trait = hana::integral(hana::metafunction<F>)
| Alias to `integral(metafunction<F>)`, provided for convenience. More...
constexpr auto | unpack
| Invoke a function with the elements of a Foldable as arguments. More...
template<typename T >
constexpr auto | value
| Return the compile-time value associated to a constant. More...
constexpr auto | value_of
| Equivalent to `value`, but can be passed to higher-order algorithms. More...
constexpr auto | while_
| Apply a function to an initial state while some predicate is satisfied. More...
template<typename M >
constexpr auto | zero
| Identity of `plus`. More...
constexpr auto | zip
| Zip one sequence or more. More...
constexpr auto | zip_shortest
| Zip one sequence or more. More...
constexpr auto | zip_shortest_with
| Zip one sequence or more with a given function. More...
constexpr auto | zip_with
| Zip one sequence or more with a given function. More...

## Detailed Description

Namespace containing everything in the library.

## Variable Documentation

## ◆ repeat

constexpr auto boost::hana::repeat
| constexpr

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.

## Example

// Copyright Louis Dionne 2013-2017
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
#include <boost/hana/assert.hpp>
#include <boost/hana/integral_constant.hpp>
#include <boost/hana/repeat.hpp>
#include <string>
namespace hana = boost::hana;
int main() {
std::string s;
for (char letter = 'a'; letter <= 'g'; ++letter)
hana::repeat(hana::int_c<3>, [&] { s += letter; });
BOOST_HANA_RUNTIME_CHECK(s == "aaabbbcccdddeeefffggg");
}
assert.hpp
Defines macros to perform different kinds of assertions.
BOOST_HANA_RUNTIME_CHECK
#define BOOST_HANA_RUNTIME_CHECK(...)
Equivalent to BOOST_HANA_RUNTIME_ASSERT, but not influenced by the BOOST_HANA_CONFIG_DISABLE_ASSERTIO...
Definition: assert.hpp:209
integral_constant.hpp
Defines boost::hana::integral_constant.
boost::hana
Namespace containing everything in the library.
Definition: accessors.hpp:20
boost::hana::repeat
constexpr auto repeat
Invokes a nullary function n times.
Definition: repeat.hpp:42
repeat.hpp
Defines boost::hana::repeat.