boost-variant Questions
3
Solved
I have declared a boost::variant which accepts three types: string, bool and int. The following code is showing that my variant accepts const char* and converts it to bool. Is it a normal behavior ...
Maiocco asked 7/11, 2012 at 11:15
3
Solved
In an answer to this SO question:
What is the equivalent of boost::variant in the C++ standard library?
it is mentioned that boost::variant and std::variant differ somewhat.
What are the differenc...
Trochanter asked 23/10, 2016 at 9:19
4
Solved
How can I check whether specific type typename T is constructible from arguments typename ...Args in the manner T{Args...}? I aware of std::is_constructible< T, Args... > type trait from <...
Prostomium asked 2/1, 2014 at 14:52
1
Solved
Boost seems to have two implementations of a variant class template:
boost::variant
boost::variant2
It is rare (though not unheard of) for Boost two include two takes on the same concept. Why has...
Portent asked 7/3, 2021 at 23:39
3
Solved
boost::variant claims that it is a value type. Does this mean that it's safe to simply write out the raw representation of a boost::variant and load it back later, as long as it only contains POD t...
Historic asked 28/7, 2009 at 15:16
4
As I understood all types of boost.variant are parsed into real types (meaning as if boost variant<int, string> a; a="bla-bla" would after compilation turn into string a; a="bla-bla") And so ...
Rickrickard asked 1/12, 2011 at 15:44
3
Solved
typedef boost::variant<int, double> Type;
class Append: public boost::static_visitor<>
{
public:
void operator()(int)
{}
void operator()(double)
{}
};
Type type(1.2);
Visitor vis...
Cathartic asked 18/10, 2012 at 12:37
1
Solved
I was updating a project to use C++17 and found a few instances where code that followed this pattern was causing a compile error on recent versions of clang:
#include <boost/variant.hpp>
s...
Kaseykasha asked 29/5, 2019 at 19:43
1
Solved
With C++14, I'm using boost::variant as a way of compile-time polymorphism:
using MyType = boost::variant<A, B>;
Both classes have a method sayHello(). I'd like to call:
MyType obj = ...;...
Minnie asked 17/5, 2019 at 9:51
2
Solved
Suppose I have a Shape base class and Circle, Line, and Point derived classes. I have two functions.
std::variant<Circle, Line, Point> process(const Shape &s);
Shape process(const Shape&...
Grackle asked 12/9, 2018 at 13:54
2
Solved
If all the types in my boost::variant support the same method, is there a way to call it generically (i.e. not calling it seperately for each method of the static_visitor)?
I'm trying to get somet...
Torchbearer asked 20/6, 2012 at 0:19
3
Solved
I have tried for hours to code a class deriving from boost::variant. But I do not understand what is the problem (I do not understand what the compilation error means).
What are the rules to imple...
Astound asked 6/12, 2012 at 19:15
2
Solved
I have a problem similar to that described here: C++ Mutually Recursive Variant Type
I am trying to create a JSON representation in C++. Many libraries already offer excellent JSON representations...
Retain asked 21/8, 2017 at 18:42
1
Solved
With std::variant<int, bool> I can call std::get<0>(var) to get the value in the variant as it's first type - int.
How can I do this with boost::variant? boost::get<> seems to su...
Leyva asked 14/8, 2017 at 14:28
3
I would like to use a boost.variant<T0,T1,T2> as a parameter to a template 'Visitor' class which would provide visitor operators as required by the boost.variant visitor mechanism, in this ca...
Latter asked 31/8, 2010 at 19:11
2
Solved
I am designing a parser for verilog language, and one of the rule have 25 components, which I need a large boost::variant to hold it:
typedef boost::variant<
shared_ptr<T_module_item__port_...
Naidanaiditch asked 10/1, 2016 at 6:5
1
Solved
I am trying to define and visit a "recursive" boost::variant using an incomplete wrapper class and std::vector as my indirection techniques. My implementation works with libstdc++, but not with lib...
Logicize asked 13/10, 2016 at 10:41
2
Solved
This Question Determined That a Non-Copyable Type Can't Be Used With Boost Variant
Tree class
template <class T = int>
class Tree{
private:
class TreeNode{
public:
std::unique_ptr No...
Beabeach asked 28/3, 2013 at 18:43
2
Solved
Assume that I have a nested boost::variant-type TNested containing some types and some other boost::variant types (that itself cannot contain again boost::variant types, so that there will be no re...
Twinkle asked 1/9, 2016 at 13:1
3
Solved
I am looking for an alternative to C-style union. boost::variant is one such option. Is there anything in std C++ ?
union {
int i;
double d;
}
Widely asked 22/3, 2012 at 22:0
1
Solved
Considering a variant type and a template function, how can I check the template type is one of the types of the variant ? Is there a more elegant way than the following ?
typedef boost::variant&l...
Turkey asked 31/5, 2016 at 7:2
1
Solved
I have two pointers that only one of them can be set, so I am considering using boost::variant, say: boost::variant<shared_ptr<Type1> shared_ptr<Type2>>. Type 1 and 2 are differen...
Casablanca asked 28/5, 2016 at 23:37
1
I would be happy to get and advice how to deal with boost::variant in "two dimensional manner". Sounds strange but let my code say more (hopefully):
I have coded a class called Parameter:
templat...
Lucerne asked 14/12, 2015 at 9:24
2
Solved
I have code that resembles below.
typedef uint32_t IntType;
typedef IntType IntValue;
typedef boost::variant<IntValue, std::string> MsgValue;
MsgValue v;
Instead of saying this,
IntValue...
Intrusive asked 14/4, 2015 at 3:25
2
Solved
Consider:
typedef boost::variant<T0, ..., TN> variant_T_t;
typedef boost::variant<U0, ..., UN> variant_U_t;
...
typedef boost::variant<variant_T_t, variant_U_t, ...> variant_t;
...
Succuss asked 10/6, 2013 at 16:13
1 Next >
© 2022 - 2025 — McMap. All rights reserved.