Listing 1
#include <tuple>
#include <utility>
using std::tr1::tuple;
using std::pair; using std::make_pair;
struct B
{ // base class
};
struct D : B
{ // derived class
};
int main()
{ // demonstrate construction of tuple objects
// default constructors
tuple<> t0;
tuple<int> t1; // contained int element is not initialized
tuple<int, D> t2; // contained D element gets default constructed
// copy constructors
tuple<> t3(t0);
tuple<int> t4(t1);
tuple<int, D> t5(t2);
// construct from another tuple object
tuple<double> t6(t4); // int element converted to double
tuple<double, B> t7(t5); // D element converted to B
// construct from std::pair object
pair<int, D> p0 = make_pair(3, D());
tuple<double, B> t8(p0); // D element converted to B
// construct from individual objects
tuple<double> t9(1); // int argument converted to double
tuple<double, B> t10(1, D()); // D argument converted to B
return 0;
}