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
21
votes
4 answers

Using Boost adaptors with C++11 lambdas

I tried to compile this code: #include #include #include int main() { std::vector v{ 1,5,4,2,8,5,3,7,9 }; std::cout << *boost::min_element(v |…
petersohn
  • 11,292
  • 13
  • 61
  • 98
15
votes
3 answers

Why is ADL not working with Boost.Range?

Considering: #include #include #include int main() { auto range = boost::irange(1, 4); assert(boost::find(range, 4) == end(range)); } Live Clang demo Live GCC demo this…
Shoe
  • 74,840
  • 36
  • 166
  • 272
12
votes
2 answers

boost::range_iterator and boost::iterator_range confusion

I have been going through the boost::range library and noticed boost::range_iterator and boost::iterator_range. I am confused with these terms here. Could anyone please explain what is the difference between two and when to use what? Also, it would…
polapts
  • 5,493
  • 10
  • 37
  • 49
12
votes
3 answers

boost transform iterator and c++11 lambda

I'm trying to use boost::adaptors::transformed by providing a c++0x lambda to the adaptor. The following code does not compile. I'm using g++ 4.6.2 with boost 1.48. #include #include #include #include…
Nithin
  • 143
  • 1
  • 5
11
votes
1 answer

Why doesn't Boost.Range is_sorted require forward iterators?

The C++11 algorithms std::is_sorted and std::is_sorted_until both require ForwardIterators. However, the Boost.Range version boost::is_sorted only requires SinglePassRanges which corresponds to InputIterators. In particular, it delegates to an an…
TemplateRex
  • 69,038
  • 19
  • 164
  • 304
11
votes
1 answer

boost::adaptors::transformed followed by boost::adaptors::filtered calls function twice

I'm trying to chain a boost::adaptors::transformed (let's call it map) to a boost::adaptors::filtered (let's call it filter) - the idea is to map a fun that returns a "Maybe" (in my case, a std::pair) over a range and output only part of…
bruno nery
  • 2,022
  • 2
  • 20
  • 31
11
votes
2 answers

Composing adaptors in Boost::range

I started playing with Boost::Range in order to have a pipeline of lazy transforms in C++. My problem now is how to split a pipeline in smaller parts. Suppose I have: int main(){ auto map = boost::adaptors::transformed; // shorten the name auto…
bruno nery
  • 2,022
  • 2
  • 20
  • 31
10
votes
2 answers

What are the benefits of using boost::any_range?

What are the benefits of using boost::any_range? Here is an example: typedef boost::any_range< int , boost::forward_traversal_tag , int , std::ptrdiff_t > integer_range; void display_integers(const integer_range& rng) { …
Gabor Marton
  • 2,039
  • 2
  • 22
  • 33
10
votes
1 answer

Converting std::pair of iterators to boost::iterator_range

I have a std::multimap, and I want to create a boost::iterator_range from equal_range. I found no simple way of doing it in the documentation, so I tried the following: typedef std::multimap Map; Map…
petersohn
  • 11,292
  • 13
  • 61
  • 98
9
votes
1 answer

Fancy indexing in C++ using boost::range

I'd like to use boost::range to pull off something similar to the "fancy indexing" available in NumPy and Matlab. Specifically, I would like to select certain elements of one indexable container using elements of another container as the indices.…
dsmith
  • 304
  • 4
  • 12
9
votes
1 answer

itertools.tee equivalent in Boost::Range?

Python's itertools has tee for n-plicating iterables: def tee(iterable, n=2): it = iter(iterable) deques = [collections.deque() for i in range(n)] def gen(mydeque): while True: if not mydeque: # when the…
bruno nery
  • 2,022
  • 2
  • 20
  • 31
8
votes
1 answer

Is this a Visual Studio 2013 update 4 C++ optimizer bug or is my code wrong?

I have been seeing crashes in our software since I updated to boost 1.58 and VS2013. Only when compiler optimization is on we see that crashes. With boost 1.55 there are no crashes. I've managed to isolate the problem I'm seeing to boost::any_range…
7
votes
2 answers

why does `boost::lower_bound` take its argument by value?

The implementation of boost::lower_bound (found here) in Range 2.0 takes its argument by value. Why is this? std::lower_bound takes its argument by const ref - see here
wreckgar23
  • 1,025
  • 9
  • 22
7
votes
1 answer

Ignore or exclude code in external libraries with gcov

I am working on a project which uses a couple of boost libraries. When looking at our test reports, we have seen that test coverage information sometimes does fit to our source code. I was able to track it down to boost::range. I think it is because…
Jens
  • 9,058
  • 2
  • 26
  • 43
6
votes
2 answers

How to use `boost::range` iterators with standard iterators

I have functions that take in std::vector iterators, as in typedef std::vector Points; Points ConvexHull(Points::const_iterator first, Points::const_iterator last); I usually pass the std iterators to them, but occasionally I need to work…
Anakhand
  • 2,838
  • 1
  • 22
  • 50
1
2 3 4 5 6 7