]> git.proxmox.com Git - ceph.git/blame - 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
CommitLineData
7c673cae
FG
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
13namespace test {
14
15namespace mpl = boost::mpl;
16
17using mpl::_;
18using boost::is_convertible;
19
20BOOST_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
30typedef is_convertible<_,char const*> predicate;
31
32BOOST_PARAMETER_FUNCTION((int), sfinae, tag,
33 (deduced
34 (optional (x, *(predicate), 0))
35 )
36)
37{
38 return 1;
39}
40
41#else
42
43BOOST_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
54template<class A0>
55typename boost::enable_if<boost::is_same<int,A0>, int>::type
56sfinae(A0 const& a0)
57{
58 return 0;
59}
60
61} // namespace test
62
63int 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