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

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Revisiting Heterogeneous Containers

C++ has come a long way, but using heterogeneous containers can still be a hassle. Find out how the Boost.Any library provides a new way to safely store objects of arbitrary datatypes in a container.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

ive years ago, I explained how to simulate heterogeneous containers by storing raw pointers to polymorphic objects in an STL container. C++ has come along way since: tuples now allow you store arbitrary types in one object. Alternatively, you can replace the raw pointers with shared_ptr. And yet, a heterogeneous container that is free from the hassles of pointer syntax and other arbitrary restrictions is still elusive. This month's solution presents another technique for implementing heterogeneous containers using the Boost.Any library.

How to store objects of different types in an STL container without the restrictions and complexities of pointers?

Use the Boost.Any library to safely store objects of arbitrary datatypes in a container.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



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