Created
December 20, 2015 19:31
-
-
Save boxdot/1ccf25198107c0611460 to your computer and use it in GitHub Desktop.
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<int N> | |
struct A { | |
struct B { | |
B(int x) : x(x) {} | |
int x; | |
}; | |
}; | |
template <int N> | |
std::ostream& operator<<(std::ostream& os, const typename A<N>::B& b) { | |
return os << b.x; | |
} | |
int main(int argc, char const *argv[]) | |
{ | |
A<0>::B b(42); | |
// std::cout << b; // does not work | |
operator<<<0>(std::cout, b); // works | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment