C ++ 0x tuples don't have iterators, right?

Looking at the standard N3291, I have not found links tupleto support begin()and end(). But when I look at my notes from years ago, I seem to have written down that I need to look later. And here we are.

I can’t find a trace in tuple<...>.begin()either tuple<...>.end()the current C ++ 0x standard, is this correct? It is impossible to pass a tuple with its iterators to an algorithm, and also forcan’t-assure it, right?

tuple<int,string,double> val;
for(auto a : val) cerr << val;     // very wrong!

which, of course, is nonsense, because what should be auto?

I need confirmation that my notes contain an error and that there is no way to get these iterators for tuple elements. Or maybe there was an abandoned path in the discussion of standards?

Note. I know that you can use TMP or Variadic templates to implement code for all elements, but my question is really about iterators.

+5
source share
3 answers

The Boost . Fusion has iterable tuples - boost::fusion::vector<>- along with many adaptable boost::tuple<>for use with these iterators and algorithms ; You can take this code and change it to work with std::tuple<>.

+7
source

Iterators for tuples would be just as useful as iterators for class members. Tuples are simply not designed for this type - iterable - content.

+4
source

, . - , - . , .

, boost::any s.

+1
source

All Articles