The X: Trying to write an internal clang tidy tool that finds an expression that contains two types (A
, B
) and then throws if const A&
is implicitly convertible to B
?
Given I can find two CXXRecordDecl
for the classes, can I easily detect if A
is implicitly convertible to B
?
I've thought of walking over the constructors but that won't cover if B provides casting operators. I could walk over them both but I'm sure there are more cases that I'm missing here (like externally defined casting operators). Basically I want to detect if std::is_convertible<const B&, A>::value
would return true, something every compiler has to do when validating a cast, but very difficult for a human to write...