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
0
votes
2 answers

Loading namespace symbols inside a function for a template instantiation

I have written a templacised operator+= function and given it a unique namespace (I only want to use it sometimes, and this allows me to exlpicitly). I would like to then use that function inside another template function that uses operator+= on…
Ayjay
  • 3,413
  • 15
  • 20
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
1 answer

boost::adaptors::transformed for classes without const begin/end

I'm trying to pass an object to boost::adaptors::transformed. However, this only seems to work if that object's class defines const versions of begin and end. This is not the case for me however, because iterating over an object of this class…
Peter
  • 2,919
  • 1
  • 16
  • 35
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
0
votes
1 answer

How to create a version of boost::range::transform that has an extra paramter for capturing context

For example I have a vector std::vector source; and a struct struct Foo { int x; int y; } and I wish to do the following Foo foo; auto tr = source | boost::adaptors::transform([&](int i){return i+foo.x;}; However the above doesn't…
bradgonesurfing
  • 30,949
  • 17
  • 114
  • 217
0
votes
0 answers

Boost range with MSVC2017 produces unknown override specifier error

The following program #include #include int main() { std::vector a{1, 2, 3}; std::vector b{4, 5, 6}; boost::join(a, b); } Compiled with the following command line: /GS /W4 /Zc:wchar_t /ZI /Gm…
wally
  • 10,717
  • 5
  • 39
  • 72
0
votes
1 answer

Boost range adaptors

When using range adaptors in a find algorithm, I have to repeat all the adaptor chain to get the corresponding end() iterator. e.g: std::vector numbers = { 10, 11, 12, 13, 14, 2, 1, 3,3,50, 55} ; if ( find(numbers|reversed,99) !=…
Llopeth
  • 406
  • 5
  • 11
0
votes
1 answer

Partition a boost::range::transformed range adaptor

I am trying to partition a boost::range::transformed adaptor: #include #include #include #include #include…
Jens
  • 9,058
  • 2
  • 26
  • 43
0
votes
1 answer

Combine boost::spirit and boost::any_range?

The function boost::spirit::qi::parse() expects two iterators to define the input range. This works well if I try to parse from std::string or std::istream. Now I want implement a more generic interface for my parser. One approach was to use…
Maik
  • 541
  • 4
  • 15
0
votes
1 answer

Using Boost adaptors with std::bind expressions

I have the following code: #include #include #include #include #include struct A { A() = default; A(const A&) = delete; A&…
petersohn
  • 11,292
  • 13
  • 61
  • 98
0
votes
4 answers

boost multi_index_container and slow operator++

It is follow-up question for this MIC question. When adding items to the vector of reference wrappers I spend about 80% of time inside ++ operator whatever iterating approach I choose. The query works as following VersionView getVersionData(int…
kreuzerkrieg
  • 3,009
  • 3
  • 28
  • 59
0
votes
2 answers

boost::transform() only if value being added isn't NULL?

I have the following code: // For each trigger model (_1) (which is just a CString), do: // m_triggers.push_back(triggers.GetTrigger(static_cast(_1))) boost::transform( model.Triggers(), std::back_inserter(m_triggers), …
void.pointer
  • 24,859
  • 31
  • 132
  • 243
0
votes
1 answer

how to avoid copying in boost range transform

boost range transform requires const & for ranges in arguments. #include #include #include int main(int argc, char *argv[]) { using namespace std; vector> rt0(10,vector(15,2)); …
kirill_igum
  • 3,953
  • 5
  • 47
  • 73
-1
votes
1 answer

how to create an adaptor that will return map values based on filtered key using a predicate for key

How to create a adaptor that will return map values based on filtered key using a predicate for key? As an example: std::map map_obj; const int match_value = 0xFF00; for(auto& i : map_obj | filtered_key_map_values([match_value](key_type&…
Shaikat
  • 23
  • 1
1 2 3 4 5 6
7