[cxx-abi-dev] Proposed ABI changes for new C++0x SFINAE rules

John McCall rjmccall at apple.com
Wed Aug 18 18:30:46 UTC 2010


On Aug 11, 2010, at 10:57 AM, David Vandevoorde wrote:
> <SFINAE_diffs-3>

We should probably specify what happens when mangling an operator of unknown arity, i.e. when mangling the signature for
  template <class T> void f(decltype(&T::operator+));
I think all the existing frontends mangle this as the binary operator in all four cases (+ - * &), but it would be good to spell this out in the ABI.

Suggested wording:
  Unlike Cfront, unary and binary operators using the same symbol have different encodings. 
INSERT: When the arity of an operator name is not known, the operator is encoded as a binary operator.

This prompts interesting questions about when, exactly, we know the arity of an operator.  For example, do we know the arity here?
  template <typename T> void g(decltype(T().operator+()));

What about here?  (This comes from a Clang bug, http://llvm.org/bugs/show_bug.cgi?id=7891)
  template <int (A::*)()> struct S {};
  template <typename T> void g (S<&T::operator + >) {}
Since S is a class template, we can actually determine contextually that the 'operator+' must be unary.  If S were a function template, this wouldn't necessarily be possible.  I assume we don't actually want to require this analysis in either case.

John.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sourcerytools.com/pipermail/cxx-abi-dev/attachments/20100818/5603cb44/attachment.html>


More information about the cxx-abi-dev mailing list