I know it is not default and maybe not prefered way to use Boost Property tree. But It seems have all needed to create tree of named pointers. So I tried:
#include <boost/property_tree/ptree.hpp>
#include <iostream>
#include <string>
template <class T>
int append(T val)
{
std::cout << "hello";
return 0;
}
int main()
{
using boost::property_tree::ptree;
ptree pt;
pt.put("function-int-pointer", &append<int>);
(pt.get("function-int-pointer", NULL))(123);
// ^-- error C2064: term does not evaluate to a function taking 1 arguments
(pt.get<int(*)(int)>("function-int-pointer"))(123);
// ^-- error C2678: binary '>>' : no operator found which takes a left-hand
// operand of type 'std::basic_istream<_Elem,_Traits>' (or there is no
// acceptable conversion)
}
If it is possible I would love tham to be auto restorable (with simple .get()
not .get<T>
)
It seems like it can store pointers to functions (main reson I want to use it). But I can not get them from it( So I wonder how to store pointers in Boost property tree so that thay would be auto restorable?