Questions tagged [boost-iterators]
76 questions
13
votes
3 answers
Skipping iterator
I have a sequence of values that I'd like to pass to a function that takes a (iterator begin, iterator end) pair. However, I only want every second element in the original sequence to be processed.
Is there a nice way using Standard-Lib/Boost to…

ltjax
- 15,837
- 3
- 39
- 62
11
votes
1 answer
Using boost::iterator
I wrote a sparse vector class (see #1, #2.)
I would like to provide two kinds of iterators:
The first set, the regular iterators, can point any element, whether set or unset. If they are read from, they return either the set value or value_type(),…

Neil G
- 32,138
- 39
- 156
- 257
9
votes
1 answer
boost iterator facade and dereference() function
I'm trying to create an iterator which only can dereference to real value types, not to references.
Is this possible using boost::iterator_facade, or does it require me to have values that can be returned by adress\reference.
To be more specfic, my…

Viktor Sehr
- 12,825
- 5
- 58
- 90
7
votes
1 answer
What is the use of the nested pointer type in iterator_traits?
The std::iterator_traits class template defines 5 nested types: iterator_category, value_type, difference_type, pointer and reference. Browsing the sources of the header of both libc++ and libstdc++, one can see many uses of value_type,…

TemplateRex
- 69,038
- 19
- 164
- 304
6
votes
1 answer
What's the difference between a Boost Single Pass Iterator and a Forward Traversal Iterator?
In the New Iterator Concepts standard proposal, I am not able to decipher any useful difference between a Single Pass Iterator and a Forward Traversal Iterator.
Does the "Assertion/Note" for the "++r" row in the Forward Traversal table imply that…

Mukul M.
- 540
- 1
- 5
- 15
6
votes
3 answers
transform_iterator compile problem
HI,
I don't like posting compile problems, but I really can't figure this one out. Using this code:
#include

Dan
- 33,953
- 24
- 61
- 87
5
votes
2 answers
Transform an iterator on an unordered_map with pointer value type to an iterator on the same map with const reference value type
I have the following class :
#include
#include
class Node {
public:
typedef std::unique_ptr ptr_type;
typedef std::unordered_map map_type;
typedef /**???**/ const_iterator;
…

AntoineWDG
- 539
- 2
- 11
5
votes
1 answer
Implement lazy generator as forward_iterator in C++
MyGenerator represents a (possibly) finite sequence of integers, that is expensive to compute. So I don't want to generate them all upfront and put them into a container.
struct MyGenerator{
bool HasNext();
int Next();
}
To print them…

Niklas
- 3,753
- 4
- 21
- 29
4
votes
1 answer
Iterator for all combinations of 2 ranges
Is it possible to use the boost::iterators library to create iterators that show the combined results of 2 ranges? Note that for usage, we need the output to be iterators. Nor do we expect to first manually create a vector of all combinations.…

JVApen
- 11,008
- 5
- 31
- 67
4
votes
3 answers
In boost, how to pass boost iterator to a function somehow casted as std::string
See specific question as a comment at the end of the following code.
std::string s("my sample string \"with quotes\"");
boost::escaped_list_separator
els(""," ","\"\'");
boost::tokenizer >::iterator…

user497804
- 292
- 2
- 7
4
votes
1 answer
I've written C++ code to treat boost::optional as a range but it doesn't compile
I wish to treat boost::optional as a container that can have zero or one elements in it. Logically I should be able to create an iterator to the container and use boost::for_each on it as well. My attempt is below but it fails to compile. I have…

bradgonesurfing
- 30,949
- 17
- 114
- 217
4
votes
2 answers
Is {} a valid argument to pass to a function expecting an iterator (representing std::end() of some container)?
In boost directory_iterator example - how to list directory files not recursive (see this answer) is the sample code
#include
#include
#include
...
using namespace…

Dan Nissenbaum
- 13,558
- 21
- 105
- 181
4
votes
2 answers
Why boost filter_iterator has weird make_filter_iterator function?
after some pain I managed to hack together this minimal example of boost filter_iterator
using namespace std;
std::function stlfunc= [](uint32_t n){return n%3==0;};
int main()
{
vector…

NoSenseEtAl
- 28,205
- 28
- 128
- 277
4
votes
1 answer
reading a file of key-value pairs in to a std::map
I have a Visual Studio 2008 C++03 project where I would like to read a file of key-value pairs in to a std::map.
To do that I've created an istreambuf_pair_iterator as below:
typedef std::map< std::string, std::string > Properties;
class…

PaulH
- 7,759
- 8
- 66
- 143
3
votes
3 answers
C++ boost::ptr_vector::iterator problem
I have this class:
template
class Task
{
private:
timeval start;
boost::ptr_vector states;
boost::ptr_vector
policies; public: P findPolicy(S *state); S findState(S *state); }; When I…

Ælex
- 14,432
- 20
- 88
- 129