I know that C++17 introduced template< auto >
, but the following example doesn't use it, yet still only compiles in C++17:
struct Foo
{
int bar;
};
template< int Foo::* >
void takePtrToMember() {}
int main()
{
takePtrToMember< &Foo::bar >(); // This works everywhere
constexpr auto x = &Foo::bar;
takePtrToMember< x >(); // This only works in C++17
return 0;
}
Why doesn't it work in C++11? What has changed in C++17 so it's now allowed there?
Aucun commentaire:
Enregistrer un commentaire