Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

pair

Description

Fusion pair type is a half runtime pair. A half runtime pair is similar to a std::pair, but, unlike std::pair, the first type does not have data. It is used as elements in _map_s, for example.

Synopsis
template <typename First, typename Second>
struct pair;

namespace result_of
{
    template <typename First, typename Second>
    struct first;

    template <typename First, typename Second>
    struct second;

    template <typename First, typename Second>
    struct make_pair;
}

template <typename First, typename Second>
typename result_of::make_pair<First,Second>::type
make_pair(Second const &);
Template parameters

Parameter

Description

First

The first type. This is purely a type. No data is held.

Second

The second type. This contains data.

Notation

P

Fusion pair type

p, p2

Fusion pairs

F, S

Arbitrary types

s

Value of type S

o

Output stream

i

Input stream

Expression Semantics

Expression

Semantics

 

P::first_type

The type of the first template parameter, F, equivalent to result_of::first<P>::type.

 

P::second_type

The type of the second template parameter, S, equivalent to result_of::second<P>::type.

 

P()

Default construction.

 

P(s)

Construct a pair given value for the second type, s.

 

P(p2)

Copy constructs a pair from another pair, p2.

 

p.second

Get the data from p1.]] [[p = p2] [Assigns a pair, p1, from another pair, p2.]] [[make_pair<F>(s)] [Make a pair given the first type, F, and a value for the second type, s. The second type assumes the type of s]] [[o << p] [Output p to output stream, o.]] [[i >> p] [Input p from input stream, i.]] [[p == p2] [Tests two pairs for equality.]] [[p != p2`

Tests two pairs for inequality.

Header
#include <boost/fusion/support/pair.hpp>
#include <boost/fusion/include/pair.hpp>
Example
pair<int, char> p('X');
std::cout << p << std::endl;
std::cout << make_pair<int>('X') << std::endl;
assert((p == make_pair<int>('X')));

PrevUpHomeNext