ifndef PROBLEMEXAMPLE_HPP define PROBLEMEXAMPLE_HPP template class str

 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
#ifndef PROBLEMEXAMPLE_HPP
#define PROBLEMEXAMPLE_HPP
template<class T>
struct Traits{};
template <class P>
class A;
template <class P>
typename Traits<A<P> >::result_type
f(A<P>& a);
template <class P>
class A{
int val;
typedef double result_type;
friend struct Traits<A<P> >;
friend
typename Traits<A<P> >::result_type
(::f<>)(A<P>& a);
};
template<class P>
struct Traits<A<P> >{
typedef typename A<P>::result_type result_type;
};
template <class P>
typename Traits<A<P> >::result_type
f(A<P>& a){
return a.val;
}
#endif // PROBLEMEXAMPLE_HPP