C++ boost::tuple














































C++ boost::tuple



The library boost.tuple provides a class called boost::tuple, which is a generalized version of std: : pair. While std :: pair can only store exactly two values, boost :: tuple lets you choose how many values to store.

Code:

#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple_io.hpp> #include <string> #include <iostream> int main() { typedef boost::tuple<std::string, int> animal; animal a{"cat", 4}; std::cout << a << '\n'; }

Output: cat 4

Comments