2

in clang vs gcc trunk (as of March 2020) I find strange behaviour in function lookup (can you please educate me on how this is actually called, does it belong to overload resolution?) when using operators.

#include <vector>

template <typename T>
void blub(std::vector<T> const& i) {
  -i;
  //getsize(i); //this also fails in gcc
}

int operator-(std::vector<int> const& i) {
    return i.size();
}

int getsize(std::vector<int> const& i) {
    return i.size();
}


int main() { blub(std::vector<int>{1}); }

When using a function like getsize instead of the unary operator, neither gcc nor clang compile, but using operator-, gcc compiles, clang doesn't. clang is right here, isn't it?

See https://godbolt.org/z/hgGeH3

nnolte
  • 1,628
  • 11
  • 25

0 Answers0