3 as_pair
Edouard A. edited this page 10 years ago

Synopsis

template <typename L>
struct as_pair;

Description

Transforms a sequence of two elements into a std::pair.

When to use

Use this adapter when you want to adapt your sequence to an std::pair, for example because you are using a function that requires an std::pair as an argument.

Header

#include <brigand/adapted/as_pair.hpp>

Parameters

  • L - A sequence of exactly two elements

Example

#include <utility>

#include <brigand/adapted/as_pair.hpp>
#include <brigand/sequences/list.hpp>

using the_list = brigand::list<int, char>;
// any sequence of two elements is accepted by as_pair
using the_pair = brigand::as_pair<the_list>;

// equivalent of writing std::pair<int, char>
the_pair p;

See also

as_tuple, as_variant, list