Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/config/test/boost_no_sfinae.ipp @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 1.1 KB
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
12namespace boost_no_sfinae {
13
14namespace f1_a {
15template <typename T>
16int f1(T*, float)
17{
18  return 0;
19}
20} using f1_a::f1;
21
22namespace f1_b {
23template <typename T>
24int f1(T*, int, typename T::int_* = 0)
25{
26  return 1;
27}
28} using f1_b::f1;
29
30namespace f2_a {
31template <typename T>
32int f2(T*, float)
33{
34  return 2;
35}
36} using f2_a::f2;
37
38namespace f2_b {
39template <typename T>
40typename T::int_ f2(T*, int)
41{
42  return 3;
43}
44} using f2_b::f2;
45
46struct test_t
47{
48  typedef int int_;
49};
50
51struct test2_t {};
52
53int 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.