Closed carolinebeltran closed 4 years ago
You can't return different types for a visitor. The return type must be the same, e.g.
struct SizeOf
{
template<class T>
std::size_t operator()(T const&) { return sizeof(T); }
};
Then you can do something like:
std::cout << "internal size: " << bustache::visit(SizeOf{}, result->second);
That said, I'm not sure what you're trying to do actually. Bustache is mostly for formatting, it's seldom that you want to introspect the model value.
Thank you Jamboree. I do use Bustache as designed for formatting. I just have a special case where I would like to look up information stored inside the container.
Jamboree, I thought that the following modification would not be difficult but I cannot figure out how to make the Printer object return values, for example:
std::cout << bustache::visit(Printer{}, result->second) << '\n';
I tried to modify the operator so that a value is returned.
Of course, I was unable to figure out how to get values returned.