Questions tagged [boost-range]

Boost.Range is a C++ library containing a collection of concepts and utilities, range-based algorithms, as well as range adaptors that allow for efficient and expressive code.

Boost.Range is a C++ library containing a collection of concepts and utilities, range-based algorithms, as well as range adaptors that allow for efficient and expressive code.

Using Boost.Range inplace of the standard library alternatives results in more readable code and in many cases greater efficiency.

104 questions
2
votes
2 answers

How to use boost::range::adaptors::transformed over std::unordered_set?

I'm trying to use boost::adaptors::transformed over a std::unordered_set but seems to produce weird behaviors even on quite small experiments. I'm using Boost 1.58.0 on Ubuntu 16.04 with gcc 5.4.0. Added elements after range initialization are not…
CaTo
  • 69
  • 1
  • 8
2
votes
1 answer

boost range adaptor flattened

I see how to write a flattening iterator, but how can I do the same thing with a boost range adaptor? I want this to work: vector> input({{1, 2}, {3, 4}}); vector result; boost::copy(input | flattened, back_inserter(result)); //…
Jay Bazuzi
  • 45,157
  • 15
  • 111
  • 168
2
votes
1 answer

Creating an unindent algorithm using boost::range

I'm creating an unindent algorithm for a text-editor. I've managed to obtain the range to operate on, but when I want to do the Gtk::TextBuffer::erase, it fails: void unindentSelection(const Glib::RefPtr &buffer) { …
chila
  • 2,372
  • 1
  • 16
  • 33
2
votes
1 answer

Compilation issue with boost range copy of filesystem path

The following code fails to compile with 1.58 while it was compiling with 1.46. I guess it's a type conversion issue, but I can't make it right. my code #include #include #include…
tibur
  • 11,531
  • 2
  • 37
  • 39
2
votes
2 answers

boost multi_index_container, range mutating algorithms and constness

I'm using boost multi_index_container, which is queried by equal_range and the result returned from the function using range::join and boost::any_range The any_range Reference argument is defined as const reference to the type - must be const…
kreuzerkrieg
  • 3,009
  • 3
  • 28
  • 59
2
votes
1 answer

Appending ranges in loop

I would like to concatenate ranges returned by function into one big range.Consider following code: some_type_i_cant_figure_out bar() { typedef std::vector::const_iterator iter; std::vector aaa; /* fill some data into aaa*/ …
kreuzerkrieg
  • 3,009
  • 3
  • 28
  • 59
2
votes
1 answer

boost::transformed with tuple functor gives strange warning

I've written a convenient functor wrapper for tuple std::get. When using it with boost transformed and operator[], I get warning that I'm returning reference to local temporary object. My system: ubuntu 14.04, compilers: clang-3.5 and g++-4.8.2,…
2
votes
0 answers

Combining ranges with boost::range::join()

I want to iterate over the lines of several files. So I made a line_iterator, and then tried to combine it with boost::range::join: class line { std::string data; friend std::istream& operator>>(std::istream& is, line& line) { return…
aaronstacy
  • 6,189
  • 13
  • 59
  • 72
2
votes
1 answer

Boost filtered adaptor compiling

I run into problems with boost::adaptors::filtered. There is a sample for demonstrating the problem struct IsRegex { IsRegex() {} // filter_iterator requires default constructible predicate explicit IsRegex(const boost::regex &rx) : m_rx(rx)…
Loom
  • 9,768
  • 22
  • 60
  • 112
2
votes
1 answer

How to iterate over two STL-like containers (Cartesian product)

I'd like to reduce the following with BOOST typedef std::vector::const_iterator Iterator; for(Iterator i = v1.begin(), ie = v1.end(); i != ie; ++i) { for(Iterator j = v2.begin(), je = v2.end(); j != je; ++j) { doSomething( *i, *j ); …
Loom
  • 9,768
  • 22
  • 60
  • 112
2
votes
1 answer

boost::iterator_range from a templated iterator

I'm trying to write a C++ version of Python's itertools.tee for Boost::Range (as seen here). Here is my first attempt: template class tee_iterator : std::iterator
bruno nery
  • 2,022
  • 2
  • 20
  • 31
2
votes
1 answer

How to return an iterator_range

I would like to create and hold on to an iterator_range. The range is constructed based on a predicate (for this example, I look for even numbers). I can do this, but it seems I must make a copy elements from the underlying vector that is being…
rcohn
  • 23
  • 1
  • 5
1
vote
5 answers

C++ algorithms that create their output-storage instead of being applied to existing storage?

The C++ std algorithms define a number of algorithms that take an input and an output sequence, and create the elements of the output sequence from the elements of the input sequence. (Best example being std::transform.) The std algorithms obviously…
Martin Ba
  • 37,187
  • 33
  • 183
  • 337
1
vote
1 answer

Extending iterator of boost::filtered to support operator+ overload

I would like to add a operator+ overload to boost::filter_iterator as in below example. However I am getting an error in the resolution of the template parameters to the operator+ overload function. #include #include #include…
1
vote
0 answers

difficulties in using ranges with dynamic polymorphism

Suppose the following // interface that provides a range of ints struct C { virtual RangeOfInts foreach() const = 0; }; struct B { void g(const C& c_) { for (int i : c_.foreach()) { // do something } …
zhaomin
  • 381
  • 3
  • 13