include iostream include utility template class struct TA struct m_b s

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <utility>
template <class T>
struct TA{
struct B{
} m_b;
};
struct A{
struct B{
} m_b;
};
namespace std{
template<class T>
ostream& operator<<(ostream& os, const pair<T, T> &v)
{
os << "( " << v.first << ", "<< v.second << ")";
return os;
}
template<class T>
ostream& operator<<(ostream &os, const typename TA<T>::B& b)
{
return os;
}
ostream& operator<<(ostream &os, const A::B& b)
{
return os;
}
}
int main (int argc, char * const argv[]) {
TA<int> ta;
// std::cout << ta.m_b; // error
A a;
std::cout << a.m_b; // ok
std::pair<int, int> p;
std::cout << p; //ok
return 0;
}