Magical type trait operators
David Vandevoorde
daveed at edg.com
Thu May 6 20:32:17 UTC 2010
The C++0x standard library has metaprogramming facilities (like the std::is_convertible) that require "magical" support from the compiler. The principal implementations seem to have converged on nearly-identical "operators" for this. E.g., std::is_convertible is typically implemented with an operator __is_convertible_to(T, U).
Now, I _think_ that if code is written only in terms of the standard templates, the operator invocations won't appear in ABI signatures, but I'd like confirmation of that.
Even so, would it be worthwhile to specify what the magical operators are, and how they are mangled?
Here is an example to illustrate:
struct A {
A();
A(A const&);
~A();
operator int();
};
template<class T> auto f(T p)->decltype(__is_convertible_to(T, int) ? p : 0) {
return p;
}
int main() {
A a;
f(a);
}
Daveed
More information about the cxx-abi-dev
mailing list