Questions tagged [boost-adaptors]
10 questions
5
votes
1 answer
boost range adaptor that makes a collection
I want to write a boost adaptor to put at the end of a chain of adaptors to create a collection, like this:
set s = input | filtered(...) | transformed(...) | to_set;
Using Method 3.1 I wrote the code below which seems to work as…

Jay Bazuzi
- 45,157
- 15
- 111
- 168
3
votes
0 answers
Understanding composition of lazy range-based functions
TL;DR
What's wrong with the last commented block of lines below?
// headers and definitions are in the down the question
int main() {
std::vector v{10,20,30};
using type_of_temp = std::vector,int>>;
//…

Enlico
- 23,259
- 6
- 48
- 102
3
votes
1 answer
Implementing a Boost range adaptor reversed_if
I regularly encounter situations in my code in which I would like to iterate over a range in direct or in reverse order depending on a runtime condition. This typically results in code like the following
if (reverse) {
using…

Christophe Fuzier
- 689
- 5
- 11
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
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
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
0
votes
1 answer
Why can't I use boost::adaptor::map_values outside a ranged-based loop?
I want to use boost's boost::adaptor::map_values to construct a vector of all values of a std::map. Take this example code (or try it at Godbolt):
#include
#include
std::vector…

Lukas Barth
- 2,734
- 18
- 43
0
votes
3 answers
Concatenate multiple ranges without copying
I want to concatenate multiple ranges (e.q.vectors) in to a single range without copying them to a new container, so that the performance is better.
It is for iterating over the whole range later.
#include
#include
#include…

shaaa
- 503
- 1
- 4
- 16
0
votes
1 answer
Two Questions About Lambda Use With boost::adaptors::filtered()
Please consider this non-compiling code:
#include
class Stuff {
public:
bool var;
};
class Manager {
/// Get everything
std::vector
get_all_stuff() const
{
return list_of_stuff;
}
/// Get a vector of…

Lance E.T. Compte
- 932
- 1
- 11
- 33
0
votes
1 answer
Random access of boost::transformed_range via boost::any_range
I'm trying to use boost::any_range (with random access tag) in some legacy code, but found that it does not like lambdas. Compilation error seems to complain about the lack of default constructor for lambda objects. Is this expected behavior? Is it…

Alexey E
- 11
- 1