私はboost::functionオブジェクトの次の定義を持っています:
typedef boost::function<std::string (std::string, std::string)> concat;
この関数を構造体コンストラクター引数として渡します。
struct add_node_value_visitor : boost::static_visitor<>
{
typedef boost::function<std::string (std::string, std::string)> concat;
add_node_value_visitor(concat _func, std::string key) : _func_concat(_func), _key(key) {}
template <typename T>
void operator() ( const T& value) const
{
std::string result = _func_concat(boost::lexical_cast<std::string, T>(value), _key);
}
std::string _key;
concat _func_concat;
};
struct add_node_value_visitor
ここで、を次の関数に渡す必要がありますがboost::function<T>
、は2 argメンバー関数を受け入れません。ドキュメントでは、boost :: bindを使用する必要があると書かれていますが、それをどのように行うかはわかりません。また、boost::apply_visitor関数を満たす必要があります。
boost::apply_visitor( add_node_value_visitor( &Decomposer::ConcatValues, key), var); // ConcatValues takes 2 args, var = boost::variant
std::string ConcatValues(std::string str, std::string key);
誰かアイデアはありますか?