blob: d7be273aa42192ec940738ceac9c81134c17195b (
plain)
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
|
bool f(int i) { return i != 5; }
template <class X, class P = bool(X)>
struct Traits
{
typedef P type;
};
template <class X, class P = typename Traits<X>::type>
struct S
{
const P& p_;
S( const P& p ) : p_(p) {} // const reference
};
template <class X>
S<X> make_s(const typename Traits<X>::type & p) // const reference
{
return S<X>(p); // << HERE
}
int main()
{
make_s<int>(f);
}
|