|
Boost : |
Subject: Re: [boost] Interest in a container which can hold multiple data types?
From: Boris Rasin (boris_at_[hidden])
Date: 2015-05-05 18:23:31
On 5/6/2015 1:08 AM, James Armstrong wrote:
> Do you mean something that would work along the lines of...
>
> std::vector<boost::any> my_vec;
> // fill my_vec with various data types
>
> //iterate through doubles
> for (auto itr = itr_begin<double>(my_vec); itr != itr_end<double>(my_vec);
> ++itr)
> {
> // ...
> }
>
> //iterate through strings
> for (auto itr = itr_begin<std::string>(my_vec); itr !=
> itr_end<std::string>(my_vec); ++itr)
> {
> // ...
> }
>
> where itr_begin and itr_end generate iterators for the templated type over
> any container of type erased objects. I didn't quite get what you were
> suggesting at first, but yeah I think I agree that would be more useful.
Yes. And this would work with std::vector<boost::any> and
std::list<boost::variant> alike.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk