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
1
vote
1 answer

Conditional boost::range::join

I want to write a function like this: template void CheckAndProcessIterables(IterableType& a, IterableType& b, IterableType& c) { IteratorRangeType range{}; // empty range if (Check(a)) { range = boost::range::join(range,…
Denis Sheremet
  • 2,453
  • 2
  • 18
  • 34
1
vote
1 answer

Interface with BOOST Range

Motivation & Approach I'm writing a small library which provides an AST structure & some algorithms to navigate over it. In simple, the AST has the following structure: struct ASTNode; using tBranch = std::vector; struct ASTNode { /*…
Kirill Rud
  • 217
  • 3
  • 9
1
vote
0 answers

Unexpected behavior of boost::adaptors::transformed when the transformation function returns by value

Consider the following piece of C++11 code which is the smallest reproducer I could come up with: #include #include std::vector myTransform(const std::vector& iVector) { return…
koral
  • 442
  • 3
  • 11
1
vote
1 answer

Proper way of declaring `const` `boost::range`s

When using boost::any_range, what's the correct way of specifying that the underlying container (if any) shouldn't be modified? E.g., with the alias template using Range = boost::any_range; to declare a…
Anakhand
  • 2,838
  • 1
  • 22
  • 50
1
vote
2 answers

Construct new container from transformed range

In my code, I frequently have to create a new container from a previously transformed range. So far I have used a combination of boost::adaptors::transformed and boost::copy_range to do the job, thinking that the container's constructor should be…
maxj
  • 45
  • 4
1
vote
1 answer

How can I avoid the boost::compute::zip_iterator and boost::iterators::zip_iterator confict when using boost compute and boost::range together?

I'd like to use boost::compute and boost::range together, like below, but if I uncomment the #include line I get an error saying that boost::compute::zip_iterator and boost::iterators::zip_iterator are ambiguous. Is there a…
1
vote
0 answers

Adjacent adaptor using boost::range

I'm asking myself if it is possible to extend boost-range by an adaptor, which I call adjacentAdaptor. This adaptor should basically iterate over all pairs of adjacent elements in a vector, list and so on. I think this function is very useful in my…
Aleph0
  • 5,816
  • 4
  • 29
  • 80
1
vote
2 answers

Can boost range transform adjacent elements in a range?

If I have a range and I want to transform adjacent pairs is there a boost range adaptor to do this? for example std::vector a; a.push_back(1); a.push_back(2); a.push_back(3); auto b = a | boost::range::transformed([](int x, int y){return…
bradgonesurfing
  • 30,949
  • 17
  • 114
  • 217
1
vote
2 answers

Algorithm find an element in a container with a given value for one of its members

Something that I have to do quite often is finding a member in a collection of elements which has an element with a given value. For example given: class Person { string getName() const {return mName;} private: string…
1
vote
1 answer

c++ boost range adaptor multiple vectors

I have just recently started using the range adaptor in boost when I had to perform a transform/function on a vector. Below is a snippet of one of the simplest example I came across when starting to use the range adaptor. int multiplyByTwo(int n) {…
Zen
  • 283
  • 1
  • 3
  • 4
1
vote
1 answer

Is possible to hide underlying containers with boost range?

I have a graph structure where vertices can have several types of edges. Vertex types are polymorphic and they must be able to "classify" edges depending on their type and store them accordingly, but I want to be able to retrieve all edges at "base…
CaTo
  • 69
  • 1
  • 8
1
vote
2 answers

compare nested iterators after boost transformed()

vector> input{ { { 1, 2 },{ 3, 4 } } }; auto result = input | boost::adaptors::transformed([](const auto& _) {return _; }); result.begin()->begin() == result.begin()->end(); If I run this w/ VS2015 with _ITERATOR_DEBUG_LEVEL=2, then it…
Jay Bazuzi
  • 45,157
  • 15
  • 111
  • 168
1
vote
1 answer

boost::range::combine with repeated argument

I would like to use boost::range::combine as a cartesian power instead as just a product. So instead of such expression boost::range::combine(myRange, myRange, myRange); write something like myCombine(myRange, 3);. How it can be implemented?
Yaroslav Kishchenko
  • 475
  • 1
  • 4
  • 15
1
vote
1 answer

How do I boost::range::sort() a boost::transformed_range?

I want to get the unique elements from a vector based on a member of foo. I am using boost::adaptors::transform to select the member, then sorting, then using boost::adaptors::unique. I'm having trouble getting the sort step to work. Leaving…
Matt Chambers
  • 2,229
  • 1
  • 25
  • 43
1
vote
0 answers

What GCC vs clang optimizer differences cause this code to not be optimized?

If I compile the following code: #include template auto iota(Integer last) { return boost::irange(0, last); } template auto iota(Integer last, StepSize step_size) { …
einpoklum
  • 118,144
  • 57
  • 340
  • 684