...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
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.
template <typename First, typename Second> struct pair; namespace result_of { template <typename Pair> struct first; template <typename Pair> 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 &);
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 |
---|---|
|
The type of the first template parameter, |
|
The type of the second template parameter, |
|
Default construction. |
|
Construct a pair given value for the second type, |
|
Copy constructs a pair from another pair, |
|
Get the data from |
|
Assigns a pair, |
make_pair<F>(s) |
Make a pair given the first type, |
|
Output |
|
Input |
|
Tests two pairs for equality. |
|
Tests two pairs for inequality. |
#include <boost/fusion/support/pair.hpp> #include <boost/fusion/include/pair.hpp>
pair<int, char> p('X'); std::cout << p << std::endl; std::cout << make_pair<int>('X') << std::endl; assert((p == make_pair<int>('X')));