Boost logo

Boost :

Subject: Re: [boost] Interest in a container which can hold multiple data types?
From: James Armstrong (armstrhu_at_[hidden])
Date: 2015-05-12 12:49:42

On Tue, May 12, 2015 at 8:19 AM, Boris Rasin <boris_at_[hidden]> wrote:

> There is already well established customization point for this:
> #include <utility>
> try {
> using std::get;
> auto val = get<T>(value);
> catch(...) {
> // handle exception
> }
> This already works for std::tuple, std::pair and boost::variant. One could
> also add implementation for boost::any:
> #include <boost/any.hpp>
> namespace boost {
> template<typename T>
> inline T get(const any& a)
> {
> return any_cast<T>(a);
> }
> }

Hey guys, thanks for the awesome feedback. I have to admit, I don't quite
see how the class has access to the user defined overloads of get<T> if it
hasn't explicitly been included in the class, but I tested it (defined
get<T>(boost::any& a) in my main.cpp file) and it works beautifully. Most
of the features I can think of are in now complete, I think the next step
would be to use it and test it out and get any feedback including
additional features to be included. The source can be gotten at

for anyone interested. Thanks again.

James Armstrong

Boost list run by bdawes at, gregod at, cpdaniel at, john at