Title
Overloaded comma operator with void operand
Status
open
Section
12.4.3 [over.binary]
Submitter
Nikolay Ivchenkov

Created on 2012-09-04.00:00:00 last changed 149 months ago

Messages

Date: 2012-09-04.00:00:00

Even though a function cannot take a parameter of type void, the current rules for overload resolution require consideration of overloaded operators when one operand has a user-defined or enumeration type and the other has type void. This can result in side effects and possibly errors, for example:

  template <class T> struct A {
    T t;
    typedef T type;
  };

  struct X {
    typedef A<void> type;
  };

  template <class T> void operator ,(typename T::type::type, T) {}

  int main() {
    X(), void(); // OK
    void(), X(); // error: A<void> is instantiated with a field of
                 // type void
  }
History
Date User Action Args
2012-09-04 00:00:00admincreate