I am using boost::any to store pointers and was wondering if there was
a way to extract a polymorphic data type.
Here is a simple example of what ideally I'd like to do, but currently doesn't work.
struct A {};
struct B : A {};
int main() {
boost::any a;
a = new B();
boost::any_cast< A* >(a);
}
This fails because a is ...
Hello,
I'm having trouble choosing between Boost.Any and Boost.Variant.
When should I use each one?
What are the advantages and disadvantages of each?
I am basically looking to store some states from external sources.
Thanks,
Omer
...
Hello,
I am using boost::any to have polymorphic types, I need to be able to cast an object to its base type.
class A {
public:
int x;
virtual int foo()= 0;
};
class B : public A {
public:
int foo() {
return x + 1;
}
};
int main() {
B* bb = new B();
boost::any any = bb;
bb->x = 44;
A...
I'm trying to remove a class object from list<boost::any> l
l.remove(class_type);
I tried writing something like this as a member function
bool operator == (const class_type &a) const //not sure about the arguments
{
//return bool value
}
How would you write an overload function to remove an object of class from a std::list of b...
Hello!
As far as I understand, there is no serialization (boost::serialization, actually) support for boost::any placeholder.
Does someone know if there is a way to serialize a custom boost::any entity?
The problem here is obvious: boost::any uses template-based placeholders to store objects and typeid to check if boost::any_cast is a...