Is this legal code?
#include <utility>
#include <iostream>
int main() {
const auto func2 = std::swap<int>;
}
This code seems legal to me. But the compilers don't agree with each other. GCC is happy with it, but clang gives an error.
prog.cc:8:16: error: variable 'func2' with type 'const auto' has incompatible initializer of type '<overloaded function type>'
const auto func2 = std::swap<int>;
^ ~~~~~~~~~~~~~~
So, I'm confused. Can anyone explain?
I'm using clang 9.0.0 on wandbox:
clang++ prog.cc -Wall -Wextra -I/opt/wandbox/boost-1.70.0/clang-6.0.1/include -std=c++17