Questions tagged [static-visitor]

boost::static_visitor — Convenient base type for static visitors.

Denotes the intent of the deriving class as meeting the requirements of a static visitor of some type. Also exposes the inner type result_type as required by the StaticVisitor concept.

10 questions
5
votes
3 answers

Coupling Static Visitor with a Static Polymorphism Hierarchy

The purpose of my program is to create a list of data which i can visit with a set of static visitors while using static polymorphism in my class hierarchy. I have created a hierarchy of classes utilizing static polymorphism through CRTP: class…
3
votes
2 answers

boost::variant. boost::visitor to overloaded function

I have a problem with a variant value to an overloaded function. I want to call the overloaded function with an int or string depending on what is stored in the variant. This is how I want to do that, but i can't : class X { void foo(int i, int…
Kabik
  • 65
  • 9
3
votes
2 answers

Is this visitor implementation correct?

I am implementing a visitor in order to use it with the boost variant library. I want to know if is correct to specialize boost::static_visitor<> with a const reference type. Note my question here is the following: There are any problem specializing…
3
votes
1 answer

Having a static_visitor modify a Boost recursive variant while traversing it?

I am using Boost's variant type extensively to build trees. More precisely, I parse a tree from a grammar using Boost's Qi, and then I traverse the tree to annotate each node with an integer - at least that is what I want to do. I just realized that…
Jérémie
  • 1,353
  • 9
  • 19
3
votes
1 answer

boost apply::visitor -> discards qualifiers

I have made a program using boost::variant that somehow isn't const correct. error: passing ‘const CompareTitle’ as ‘this’ argument of ‘bool CompareTitle::operator()(const T1&, const T2&) [with T1 = TestSeizoen, T2 = TestSeizoen]’ discards…
Hannah P
  • 33
  • 2
3
votes
1 answer

Boost: Why is apply_visitor not working in this code

I am getting the following compiler error: /usr/include/boost/variant/variant.hpp:832:32: error: no match for call to ‘(const StartsWith) (bool&)’ for the following code. Does anybody know why? #include "boost/variant/variant.hpp" #include…
B Faley
  • 17,120
  • 43
  • 133
  • 223
2
votes
1 answer

boost::static_visitor as Map Value

I'm trying to create a lookup table for ints to a boost::static_visitor using VariableValue = boost::variant; struct low_priority {}; struct high_priority : low_priority {}; struct Mul : boost::static_visitor <…
Tom
  • 1,235
  • 9
  • 22
1
vote
1 answer

Boost Variant conversion error when using visitor

I don't mean to code dump but this is genuinely the smallest reproducible example of this I could create even after removing all the logic to make it clearer. Essentially I'm trying to implement my own version of some of the base types in C++ to…
Tom
  • 1,235
  • 9
  • 22
1
vote
1 answer

boost::variant apply static_visitor to certain types

I have the following variant: typedef boost::variant TypeVariant; And I want to create a visitor to convert a int or float type to a bool type. struct ConvertToBool : public boost::static_visitor { TypeVariant…
Tom
  • 1,235
  • 9
  • 22
0
votes
1 answer

apply_visitor does not change object

I have inherited from boost::static_visitor<> and defined a class as follows: class move_visitor : public boost::static_visitor<> { private: double m_dx, m_dy; public: move_visitor() : m_dx(0.0), m_dy(0.0) {} move_visitor(double dx,…
Mutating Algorithm
  • 2,604
  • 2
  • 29
  • 66