Boost logo

Boost :

Subject: Re: [boost] Interest in a container which can hold multiple data types?
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2015-05-06 07:43:41


Le 06/05/15 13:24, Alex Perry a écrit :
> On 05 May 2015 23:24 Boris Rasin [mailto:boris_at_[hidden]] wrote:
>> On 5/6/2015 1:08 AM, James Armstrong wrote:
>>> Do you mean something that would work along the lines of...
>>>
> Snip...
>>> //iterate through doubles
>>> for (auto itr = itr_begin<double>(my_vec); itr !=
>> itr_end<double>(my_vec);
>>> ++itr)
>>> {
>>> // ...
>>> }
> Snip
>> Yes. And this would work with std::vector<boost::any> and
>> std::list<boost::variant> alike.
> How would this differ from using boost.range filters?
>
> eg
> #include <boost/range/adaptors.hpp>
>
> for (auto & val : boost::adaptors::filter(my_vec, []( boost::any & i) { return !i.empty() && i.type() == typeid(int); } ) )
> {
> }
>
>
I suspect the reason is efficiency?

Vicente


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk