I have a template looking like this:
struct add_node_value_visitor : boost::static_visitor<>
{
add_node_value_visitor(){}
template <typename T>
void operator() ( const T& value) const
{
boost::lexical_cast<std::string, T>(value);
}
};
The problem I have is that the visitor is used inside a for loop iterating over a bunch of values, and the resulting string of values needs to be one string, currently this would produce a bunch of separate strings, which is not what I want, so to solve this problem I thought I’d add a function pointer to the ctor of this struct so that I can pass in a function to concatenate the resulting string of each loop iteration and create one string. Then if I want to use this struct where I do not need a concatenation, I can still do that. The question is whether I should use a function pointer or is it possible to do this with something like boost::lambda?
Or would boost::function be easier to use?
Something like this?