Haruyuki Mohri


In "C++Builder", use the "boost::any"

How to use with "C++Builder FireMonkey", "boost::any".

a method using "std::vector<>" I introduced previous.
With the "boost::any", it can be utilized, such as the "void *".

#include <boost/any.hpp>
void __fastcall TForm1::FormCreate(TObject *Sender)
    boost::any obj_ = new TButton(this);
    boost::any_cast<TButton* >(obj_)->Name = "obj2";

    this->AddObject(boost::any_cast<TButton* >(obj_));

this is a method that does not aware of the type

There are ARC case of "FireMonkey". So I think that there is no need of "delete".


Incidentally the case of the "void *".

 void* obj_ = new TFmxObject(this);
    static_cast<TFmxObject* >(obj_)->Name = "obj_";

Use the "static_cast<>".