1

For example

template<class Container, class T>
bool operator==(Container const& c, std::initializer_list<T> const& l)
{
    return c.size() == l.size() && equal(c.begin(), c.end(), l.begin());
}

Check by

std::vector<int> v = {1, 2};
bool b = operator==(v, {1, 2}); // okay
b = (v == {1, 2}); // Error

Why? and How to fix it?

user1899020
  • 13,167
  • 21
  • 79
  • 154
  • `{...}` isn't a `std::initializer_list`. `{...}` has no type. The fact that it can be used in place of an initializer list requires special rules. – chris Mar 01 '17 at 05:41

0 Answers0