1

これがデフォルトではなく、Boost プロパティ ツリーを使用する方法として好ましくないことはわかっています。しかし、名前付きポインターのツリーを作成するために必要なものはすべて揃っているようです。だから私は試しました:

#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)
} 

可能であれば、自動復元できるようにしたいと思います(単純な.get()not を使用.get<T>

関数へのポインタを格納できるようです(主な理由は私がそれを使いたいからです)。しかし、私はそれからそれらを取得することはできません(だから、自動復元可能になるようにBoostプロパティツリーにポインターを保存する方法を知りたいですか?

4

1 に答える 1