]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/parameter/test/optional_deduced_sfinae.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / parameter / test / optional_deduced_sfinae.cpp
1 // Copyright Daniel Wallin 2006. Use, modification and distribution is
2 // subject to the Boost Software License, Version 1.0. (See accompanying
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4
5 #include <boost/parameter/preprocessor.hpp>
6 #include <boost/parameter/name.hpp>
7 #include <boost/type_traits/is_convertible.hpp>
8 #include <boost/tuple/tuple.hpp>
9 #include <string>
10 #include "basics.hpp"
11 #include <boost/utility/enable_if.hpp>
12
13 namespace test {
14
15 namespace mpl = boost::mpl;
16
17 using mpl::_;
18 using boost::is_convertible;
19
20 BOOST_PARAMETER_NAME(x)
21
22 // Sun has problems with this syntax:
23 //
24 // template1< r* ( template2<x> ) >
25 //
26 // Workaround: factor template2<x> into a separate typedef
27
28 #if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580))
29
30 typedef is_convertible<_,char const*> predicate;
31
32 BOOST_PARAMETER_FUNCTION((int), sfinae, tag,
33 (deduced
34 (optional (x, *(predicate), 0))
35 )
36 )
37 {
38 return 1;
39 }
40
41 #else
42
43 BOOST_PARAMETER_FUNCTION((int), sfinae, tag,
44 (deduced
45 (optional (x, *(is_convertible<_,char const*>), 0))
46 )
47 )
48 {
49 return 1;
50 }
51
52 #endif
53
54 template<class A0>
55 typename boost::enable_if<boost::is_same<int,A0>, int>::type
56 sfinae(A0 const& a0)
57 {
58 return 0;
59 }
60
61 } // namespace test
62
63 int main()
64 {
65 using namespace test;
66
67 assert(sfinae() == 1);
68 assert(sfinae("foo") == 1);
69 assert(sfinae(1) == 0);
70
71 return 0;
72 }
73