Created
July 22, 2014 18:12
-
-
Save cout/aa5d6196371f1a429f69 to your computer and use it in GitHub Desktop.
cannot specialize a member of an unspecialized template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
template<typename T, typename U> | |
class Foo | |
{ | |
public: | |
template<typename V> | |
void operator()(V const &) | |
{ | |
std::cout << "default" << std::endl; | |
} | |
}; | |
template<typename T, typename U> | |
template<> | |
void | |
Foo<T, U>:: | |
operator()<int>(int const &) | |
{ | |
std::cout << "specialized" << std::endl; | |
} | |
int main() | |
{ | |
Foo<int, double> foo; | |
foo(42); | |
} | |
// cout@ubuntu:~/tmp $ clang++ test.cpp -std=c++11 | |
// test.cpp:19:1: error: cannot specialize (with 'template<>') a member of an unspecialized template | |
// operator()<int>(int const &) | |
// ^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment