]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/parameter/test/sfinae.cpp
1 // Copyright David Abrahams, Daniel Wallin 2003. Use, modification and
2 // distribution is subject to the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt
6 #include <boost/parameter.hpp>
7 #include <boost/parameter/match.hpp>
8 #include <boost/detail/lightweight_test.hpp>
10 #include <boost/type_traits/is_convertible.hpp>
12 #if ! defined(BOOST_NO_SFINAE) && ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
13 # include <boost/utility/enable_if.hpp>
14 # include <boost/type_traits/is_same.hpp>
19 BOOST_PARAMETER_KEYWORD(keywords
,name
)
20 BOOST_PARAMETER_KEYWORD(keywords
,value
)
22 using namespace boost::parameter
;
28 , boost::is_convertible
<boost::mpl::_
, std::string
>
32 , boost::is_convertible
<boost::mpl::_
, float>
37 // The use of assert_equal_string is just a nasty workaround for a
39 void assert_equal_string(std::string x
, std::string y
)
45 void f_impl(P
const& p
)
47 float v
= p
[value
| 3.f
];
49 assert_equal_string(p
[name
| "bar"], "foo");
54 f_impl(f_parameters()());
60 , BOOST_PARAMETER_MATCH(f_parameters
, (A0
), args
))
65 template<class A0
, class A1
>
67 A0
const& a0
, A1
const& a1
68 , BOOST_PARAMETER_MATCH(f_parameters
,(A0
)(A1
), args
))
73 #if ! defined(BOOST_NO_SFINAE) && ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
74 // On compilers that actually support SFINAE, add another overload
75 // that is an equally good match and can only be in the overload set
76 // when the others are not. This tests that the SFINAE is actually
77 // working. On all other compilers we're just checking that
78 // everything about SFINAE-enabled code will work, except of course
80 template<class A0
, class A1
>
81 typename
boost::enable_if
<boost::is_same
<int,A0
>, int>::type
82 f(A0
const& a0
, A1
const& a1
)
97 f(value
= 3.f
, name
= "foo");
99 #if ! defined(BOOST_NO_SFINAE) && ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
100 BOOST_TEST(f(3, 4) == 0);
102 return boost::report_errors();