Line | |
---|
1 | // (C) Copyright Eric Friedman 2003. |
---|
2 | // Some modifications by Jeremiah Willcock and Jaakko Järvi. |
---|
3 | // Use, modification, and distribution is subject to the Boost Software |
---|
4 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
---|
5 | // http://www.boost.org/LICENSE_1_0.txt) |
---|
6 | |
---|
7 | // MACRO: BOOST_NO_SFINAE |
---|
8 | // TITLE: SFINAE (substitution failure is not an error) |
---|
9 | // DESCRIPTION: SFINAE not supported. |
---|
10 | |
---|
11 | |
---|
12 | namespace boost_no_sfinae { |
---|
13 | |
---|
14 | namespace f1_a { |
---|
15 | template <typename T> |
---|
16 | int f1(T*, float) |
---|
17 | { |
---|
18 | return 0; |
---|
19 | } |
---|
20 | } using f1_a::f1; |
---|
21 | |
---|
22 | namespace f1_b { |
---|
23 | template <typename T> |
---|
24 | int f1(T*, int, typename T::int_* = 0) |
---|
25 | { |
---|
26 | return 1; |
---|
27 | } |
---|
28 | } using f1_b::f1; |
---|
29 | |
---|
30 | namespace f2_a { |
---|
31 | template <typename T> |
---|
32 | int f2(T*, float) |
---|
33 | { |
---|
34 | return 2; |
---|
35 | } |
---|
36 | } using f2_a::f2; |
---|
37 | |
---|
38 | namespace f2_b { |
---|
39 | template <typename T> |
---|
40 | typename T::int_ f2(T*, int) |
---|
41 | { |
---|
42 | return 3; |
---|
43 | } |
---|
44 | } using f2_b::f2; |
---|
45 | |
---|
46 | struct test_t |
---|
47 | { |
---|
48 | typedef int int_; |
---|
49 | }; |
---|
50 | |
---|
51 | struct test2_t {}; |
---|
52 | |
---|
53 | int test() |
---|
54 | { |
---|
55 | test_t* t = 0; |
---|
56 | test2_t* t2 = 0; |
---|
57 | bool correct = |
---|
58 | (f1(t, 0) == 1) && |
---|
59 | (f1(t2, 0) == 0) && |
---|
60 | (f2(t, 0) == 3) && |
---|
61 | (f2(t2, 0) == 2); |
---|
62 | return !correct; |
---|
63 | } |
---|
64 | |
---|
65 | } |
---|
66 | |
---|
67 | |
---|
68 | |
---|
Note: See
TracBrowser
for help on using the repository browser.