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

How use boost range of boost :: adaptors chain get std::list

I would like to complete the following functions #include #include #include #include #include #include #include #include…
user6788115
1
vote
0 answers

Is there an idiomatic, efficient C++ equivalent to Haskell's groupBy?

I'm trying to process an input sequence with Boost.Range. The library leaves quite a lot to be desired, so I have to write some additional range adaptors on my own. Most of them are straightforward, but I ran into some difficulties when I tried to…
Yaron Tausky
  • 803
  • 2
  • 8
  • 12
1
vote
1 answer

Combination of boost range for_each, bind, copy and a back_inserter fails

I want to copy all the integers contained in a into b. #include #include #include #include #include void test() { …
lars
  • 475
  • 2
  • 6
1
vote
4 answers

Equivalent of enumerators in C++11?

In C#, you can define a custom enumeration very trivially, eg: public IEnumerable GetNestedFoos() { foreach (var child in _SomeCollection) { foreach (var foo in child.FooCollection) { yield return foo; …
Miral
  • 12,637
  • 4
  • 53
  • 93
1
vote
1 answer

How to join multiple boost ranges and return as a result from function w/o using boost::any_range

Example: SomeType bar::foo() const { SomeType retVal; for (auto i = 0u; i < 10; ++i) { retVal = boost::range::join(retVal, m_someDataContainer.equal_range(i)); } return retVal; } Lets say, for simplicity, the m_someDataContainer and…
kreuzerkrieg
  • 3,009
  • 3
  • 28
  • 59
1
vote
2 answers

boost::any_range and operator []

Consider the following code: #include #include #include #include #include #include #include #include struct TestData { …
kreuzerkrieg
  • 3,009
  • 3
  • 28
  • 59
1
vote
2 answers

Example of Input Iterator where `end()` actually denotes one-past-the end?

I'm currently trying to make sense of some ideas wrt. C++ iterators, and I have been wondering ... Given an Incremental / Single Pass / Input / Output Iterator, can there actually exist such a thing as a one-past-the-end position/element for such an…
Martin Ba
  • 37,187
  • 33
  • 183
  • 337
1
vote
1 answer

Why are Boost.Range range_begin/end free functions overloaded for both const as well as non-const references?

I found this interesting bit in Boost.Range: When providing free-standing functions range_begin/end(), the docs state that: ... range_begin() and range_end() must be overloaded for both const and mutable reference arguments. And indeed, looking…
Martin Ba
  • 37,187
  • 33
  • 183
  • 337
1
vote
1 answer

Boost-range not working with C++1y init-capture mutable lambda

I want to compute the element-wise difference of two vectors using Boost.Range and C++1y lambdas with init-capture. The simpler case of subtracting a fixed (i.e. the first) element of one vector works. However, when I try to compute the "vectorized…
TemplateRex
  • 69,038
  • 19
  • 164
  • 304
1
vote
2 answers

Using Boost.Range in C++ interfaces

I have a polymorphic interface struct Interface { Interface(SomeType& other) : range([=](){ return other.my_range(); }), /*...*/ {} Interface(SomeOtherType& other) : range([=](){ return other.some_range(); }), /*...*/ {} const…
gnzlbg
  • 7,135
  • 5
  • 53
  • 106
1
vote
1 answer

c++: use boost range transformed adaptor with binary function

Suppose I have two std::vectors x and y and a binary function F. I would like to create a new object z (not necessarily a vector), with the property that the ith elemenent of z will be the application of F to the ith elements of x and y. For the…
linuxfever
  • 3,763
  • 2
  • 19
  • 43
1
vote
1 answer

boost range adaptor similar to transformed which can access adjacent elements

I want to make a range which transformed by adjacent values of given range. Is there a way to achieve this? Thus, I want to make an adjacent_transformed which described in the code below. class Func{ public: typedef int result_type; int…
Sungmin
  • 2,499
  • 3
  • 26
  • 32
1
vote
1 answer

using transform algorithm with boost range

Hi i'm trying to add two std vectors with boost.range but i get a bunch of errors. this works: std::transform(a.begin(),a.end(),b.begin(),a.begin(),std::plus()); this doesn't: boost::transform(a,b,a,std::plus()); with an…
kirill_igum
  • 3,953
  • 5
  • 47
  • 73
1
vote
1 answer

How to implement a range adaptor with boost::joined_range

Here is an example of a range adaptor based off of Implement a Range Adaptor with arguments: #include #include #include #include #include…
Jesse Good
  • 50,901
  • 14
  • 124
  • 166
1
vote
2 answers

cout a boost::range of elements

Does Boost Ranges have a built-in way to cout the elements easily, for example separated by comma or space? I am of course aware that I could loop over them and print them separately, but it seems to me that this should be built in somehow (like…
Gurgeh
  • 2,130
  • 15
  • 28