fork(3) download
  1. #include <iostream>
  2. #include <initializer_list>
  3. using namespace std;
  4.  
  5. struct AddInitializerList {
  6. void operator+= (initializer_list<int> values) {
  7. // Do nothing
  8. }
  9.  
  10. void operator+ (initializer_list<int> values) {
  11. // Do nothing
  12. }
  13. };
  14.  
  15. int main() {
  16. AddInitializerList adder;
  17. adder += {1, 2, 3}; // Totally legit
  18. adder + {1, 2, 3}; // Not okay!
  19.  
  20. return 0;
  21. }
Compilation error #stdin compilation error #stdout 0s 15240KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:18:11: error: expected primary-expression before ‘{’ token
  adder +  {1, 2, 3};  // Not okay!
           ^
stdout
Standard output is empty