2009/12/3 Jonathan Chambers`
I'm trying to get the program to compile if the variant takes on the guise of an int (because I've implemented void operator()(int &i) const, but not compile if I make the variant take the guise of a char e.g. boost::variant
var = 'a'; because I've not implemented the void operator()(char &c) const Can anyone think of a way of doing this, maybe using SFINAE (Substitution Failure Is Not An Error)
I don't think SFINAE will help here, since you don't have a template.
What about just declaring, but not defining, the version with a char
parameter?
Though since it's a runtime distinction, I'm not convinced this will
be possible at compile-time, since it will want to compile the code
for all the runtime possibilities.
What's wrong with just throwing an exception in the char-parameter
function in the visitor? Or, alternatively, why are you using a
variant