RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Tackle Common Programming Tasks Using the New <tuple> Library

Tuples are fixed size collections of heterogeneous objects, and they are being added to the C++ standard. Learn how this powerful facility can help you simplify several common programming tasks.


he C++ standards committee is now working on updates and enhancements to the Standard Library. Tuple types are one of the recent additions to the standard. A tupleis a fixed size collection of heterogeneous objects. Tuple types are very powerful and can help you simplify several programming tasks.

How can you simulate multiple return types for a single function? How do you assign and compare multiple values simultaneously?

Use the <tuple> library to define tuple objects and manipulate them.

Author's Note: Thus far, my 10-Minute Solutions have relied solely on C++98 features that every decent compiler should support. However, the <tuple> library isn't included in your IDE's Standard Library yet. Therefore, you will need to download this library from Boost if you wish to compile the code samples included here. Even if you'd rather not install new libraries on your computer, future releases of your compiler will support <tuple> anyway.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date