Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) boost::get

 

boost::get is a Boost function to access an element from a container, for example a boost::tuple.

 

#include <iostream>
#include <string>
#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_io.hpp>

int main()
{
  boost::tuple<int,double,std::string> t
    = boost::make_tuple(123,3.14159,"Bilderbikkel");

  const int x1 = t.get<0>();
  const double x2 = t.get<1>();
  const std::string x3 = t.get<2>();

  boost::get<0>(t) = x1 + 1;
  boost::get<1>(t) = x2 + 1.0;
  boost::get<2>(t) = x3 + " was here";

  std::cout << t << '\n';
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict