Questions tagged [boost-variant]

Boost.Variant is a C++ library containing a safe, generic, stack-based discriminated union container, offering a simple solution for manipulating an object from a heterogeneous set of types in a uniform manner.

Boost.Variant is a C++ library containing a safe, generic, stack-based discriminated union container, offering a simple solution for manipulating an object from a heterogeneous set of types in a uniform manner.

Whereas standard containers such as std::vector may be thought of as "multi-value, single type," boost::variant is "multi-type, single value."

317 questions
0
votes
1 answer

How to declare a boost recursive variant in mpl::list?

How can I make this recursive variant work? I'd like to have a container of variant, or container of container of variant. template class A { // ... T t_; }; template class AVariant { typedef typename…
surfcode
  • 445
  • 1
  • 5
  • 20
0
votes
4 answers

Call function on boost::variant regardless of type?

I have a class which has a template: template class slider; The class has a void Process(void) method, so, I think it should be callable regarless of the type, return value is void and there are no parameters to it. As for now I…
user1182183
0
votes
2 answers

push to list of boost::variant's

I have the boost::variant over set of non-default constructible (and maybe even non-moveable/non-copyable and non-copy/move constructible) classes with essentialy different non-default constructor prototypes, as shown below: #include…
Tomilov Anatoliy
  • 15,657
  • 10
  • 64
  • 169
0
votes
0 answers

Traversing boost::variant types with Visitor that takes template

I've got a persistence class like: class Writer: private boost::noncopyable { template struct Record { std::vector _queued; // waiting to be persisted hsize_t _fileRows; // on disk DataSet _ds; …
jorgetown
  • 455
  • 3
  • 12
0
votes
1 answer

Boost::Variant; Defining Visitor Class

In Java, I am able to define a variable of a generic class without specifying type. class Tree> {} somewhere-else: Tree tree; I can then read in some object from a file and type-cast it to the class type I…
Mushy
  • 2,535
  • 10
  • 33
  • 54
0
votes
0 answers

Is it possible to store the return value of boost::apply_visitor in a member variable?

Is it possible to store the return value of boost::apply_visitor in the member variable of a class? I need to get Test::Do function to work, but don't know how. #include "boost/variant/variant.hpp" #include "boost/variant/apply_visitor.hpp" using…
B Faley
  • 17,120
  • 43
  • 133
  • 223
0
votes
1 answer

boost::variant object construction count VS destruction count

I've used boost::variant for some time and now I'm trying to figure out how it internally works. I wrote a simple test and I can't understand the results. Here it is (simplified) struct my_type { my_type(){ cout << (size_t)this << "…
neodelphi
  • 2,706
  • 1
  • 15
  • 22
0
votes
1 answer

Boost Variant : How can I do a visitor that returns the type that was set?

I'm trying to write a generic map that uses a boost:variant as the value. I'm stuck on trying to write the get(std::string key) function that will return the appropriate type. Here is what I came up with so far: class GenericHashMap…
Setheron
  • 3,520
  • 3
  • 34
  • 52
0
votes
0 answers

Add data to a boost property_tree

I have a simple tree structure stored in XML and use boost::property_tree::ptree to read and extract the information. I then recreate the tree using std::maps so that I can store data in the leaves. This works well and I like the separation of the…
Ant
  • 1,668
  • 2
  • 18
  • 35
0
votes
1 answer

implementing visitation class within other class

I am trying to identify the type of a boost::variant within a class object to perform the associated member functions. Consider the following code: #include #include #include #include #include…
sam
  • 43
  • 1
  • 5
0
votes
0 answers

Serialization of boost::variant

Possible Duplicate: Is it safe to serialize a raw boost::variant? I would like to serialize a boost::variant type of nonPOD classes. Would you please tell me if that is possible and show me how to do it? typedef boost::variant
Binh Van Pham
  • 111
  • 10
-1
votes
2 answers

Generating a vector with int and string arguments

I would like to use the boost library (boost::variant) in C++ to define a vector if integers and strings. I am struggling to fill a such a vector - can someone either post an example code with fills a vector with ints and strings using the Boost…
Sid
  • 266
  • 5
  • 13
-1
votes
1 answer

Rewrite type to use boost::recursive_wrapper instead of boost::make_recursive variant

I have this type using expression = boost::make_recursive_variant< number, std::tuple< boost::recursive_variant_, binary_operator, boost::recursive_variant_ > >; It doesn't matter what binary_operator is, this…
CrabMan
  • 1,578
  • 18
  • 37
-1
votes
1 answer

pointer-to-member-function type requires an rvalue

What is the matter of the error, which produces the following code? struct foo { void call(void (foo::*ptr)()) && { (*this.*ptr)(); } }; How to fix this error?
Tomilov Anatoliy
  • 15,657
  • 10
  • 64
  • 169
-2
votes
1 answer

create boost - variant type for general c struct

I am trying to create a boost::variant object which can hold any C struct in addition to other datatypes . for example -this is what I want to achieve for any struct I define: typdef struct c { int a ; double b; }c; boost::variant result; c…
micky mouse
  • 41
  • 2
  • 8
1 2 3
21
22