2010-12-22 22:31:33 +00:00
[/
Copyright 2010 Neil Groves
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
/]
2010-03-28 16:08:35 +00:00
[section:indexed indexed]
[table
[[Syntax] [Code]]
2013-01-02 08:09:46 +00:00
[[Pipe] [`rng | boost::adaptors::indexed(start_index)`]]
[[Function] [`boost::adaptors::index(rng, start_index)`]]
2010-03-28 16:08:35 +00:00
]
* [*Returns:] A range adapted to return both the element and the associated index. The returned range consists of iterators that have in addition to the usual iterator member functions an `index()` member function that returns the appropriate index for the element in the sequence corresponding with the iterator.
2010-04-28 18:03:26 +00:00
* [*Range Category:] __single_pass_range__
2010-12-22 23:42:02 +00:00
* [*Range Return Type:] `boost::indexed_range<typeof(rng)>`
2010-04-28 18:03:26 +00:00
* [*Returned Range Category:] The range category of `rng`
2010-03-28 16:08:35 +00:00
[section:indexed_example indexed example]
2013-01-03 23:44:30 +00:00
[import ../../../test/adaptor_test/indexed_example.cpp]
[indexed_example]
2010-03-28 16:08:35 +00:00
[endsect]
This would produce the output:
``
Element = 10 Index = 0
Element = 20 Index = 1
Element = 30 Index = 2
Element = 40 Index = 3
Element = 50 Index = 4
Element = 60 Index = 5
Element = 70 Index = 6
Element = 80 Index = 7
Element = 90 Index = 8
``
[endsect]