1#include <boost/tuple/tuple.hpp>2#include <boost/tuple/tuple_io.hpp>3#include <boost/tuple/tuple_comparison.hpp>4#include <iostream>5#include <string>6 7 voidTestTuple1 ()8 {9typedef BOOST::TUPLE<STD::string, std::string>Person ;TenPerson P ("Kevin"," -"); OneStd::cout << P <<Std::endl; AStd::cout << boost::make_tuple (boost::ref(p),"male", -) <<Std::endl; - } - the voidTestTuple2 () - { - using namespacestd; -typedef boost::tuple<string,string,int>Person ; +Person P ("Kevin","male", -); -cout << p.Get<0> () <<Endl; +P.Get<1> () ="Lihua"; Acout << Boost::Get<1> (P) <<Endl; at } - - voidTestTuple3 () - { - using namespacestd; -typedef boost::tuple<string,string,int>Person ; inperson P1 = Boost::make_tuple ("Kevin","male", -); -person P2 = boost::make_tuple ("Lihua","female", -); to +cout << (P1! = p2) <<Endl; - } the *BOOST::TUPLE<STD::string,int>func () $ {Panax Notoginseng returnBoost::make_tuple ("Func Error",2003); - } the + voidTestTuple4 () A { theSTD::stringerr_msg; + intErr_no; - $Boost::tie (err_msg, err_no) =func (); $Std::cout <<"Error:"<< err_msg <<"Error No:"<< Err_no <<Std::endl; - } - the voidTestshujujiegou () - {Wuyi TestTuple4 (); the}
Boost C + +: Data structure---tuple