Skip to content

Instantly share code, notes, and snippets.

@boxdot
Created December 20, 2015 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boxdot/1ccf25198107c0611460 to your computer and use it in GitHub Desktop.
Save boxdot/1ccf25198107c0611460 to your computer and use it in GitHub Desktop.
#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