How do I check if a given type T can be implicitly converted to some type S at compile-time? I'm trying to write a signature constraint for a template function that should only be instantiated if the parameter type can be implicitly assigned to some given type S.
struct S(T) { T value; void setValue(S)(S newValue) if ( /* ???? */ ) { value = newValue; } I tried __traits(compiles, value = newValue) but it seems to always return true, and then later the compiler errors out at the actual assignment statement. I'd like to be able to catch this at the signature constraint instead of inside the function body. T -- If you look at a thing nine hundred and ninety-nine times, you are perfectly safe; if you look at it the thousandth time, you are in frightful danger of seeing it for the first time. -- G. K. Chesterton