I'm trying to find a way to see if a given object is convertible to std::string, but with certain restrictions. Normally, is_convertible<> would be fine, but in this case it doesn't work for my needs.
Here's the situation in more detail. I've got a class Foo with a string conversion operator:
class Foo { public: operator std::string () const; };
I want some kind of is_convertible
to return FALSE, but something like is_convertible to return TRUE. Basically, I want is_convertible to check to see if the target type (std::string) has an implicit constructor taking the input type; I *don't* want is_convertible to check to see if the input type has a conversion-to-target-type function. Is there a way to do this?
Yes, it's quite cunning and we use it to implement is_enum: a conversion
sequence is only permitted one user defined conversion, so try:
is_convertible