]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/parameter/test/preprocessor.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)
5 #include <boost/parameter/preprocessor.hpp>
6 #include <boost/parameter/keyword.hpp>
7 #include <boost/type_traits/is_const.hpp>
11 #ifndef BOOST_NO_SFINAE
12 # include <boost/utility/enable_if.hpp>
17 BOOST_PARAMETER_BASIC_FUNCTION((int), f
, tag
,
28 typedef typename
boost::parameter::binding
<
29 Args
, tag::index
, int&
32 BOOST_MPL_ASSERT((boost::is_same
<index_type
, int&>));
43 BOOST_PARAMETER_BASIC_FUNCTION((int), g
, tag
,
54 typedef typename
boost::parameter::binding
<
55 Args
, tag::index
, int const&
58 BOOST_MPL_ASSERT((boost::is_same
<index_type
, int const&>));
69 BOOST_PARAMETER_FUNCTION((int), h
, tag
,
76 (out(index
), (int), 2)
80 # if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) \
81 && !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
82 BOOST_MPL_ASSERT((boost::is_same
<index_type
, int>));
94 BOOST_PARAMETER_FUNCTION((int), h2
, tag
,
101 (out(index
), (int), (int)value
* 2)
105 # if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) \
106 && !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
107 BOOST_MPL_ASSERT((boost::is_same
<index_type
, int>));
121 template <class Args
>
122 base(Args
const& args
)
134 BOOST_PARAMETER_CONSTRUCTOR(class_
, (base
), tag
,
145 BOOST_PARAMETER_BASIC_MEMBER_FUNCTION((int), f
, tag
,
165 BOOST_PARAMETER_BASIC_CONST_MEMBER_FUNCTION((int), f
, tag
,
185 BOOST_PARAMETER_MEMBER_FUNCTION((int), f2
, tag
,
196 tester(name
, value
, index
);
200 BOOST_PARAMETER_CONST_MEMBER_FUNCTION((int), f2
, tag
,
211 tester(name
, value
, index
);
216 BOOST_PARAMETER_MEMBER_FUNCTION((int), static f_static
, tag
,
227 tester(name
, value
, index
);
232 BOOST_PARAMETER_FUNCTION(
235 (name
, (std::string
))
242 #ifndef BOOST_NO_SFINAE
243 // On compilers that actually support SFINAE, add another overload
244 // that is an equally good match and can only be in the overload set
245 // when the others are not. This tests that the SFINAE is actually
246 // working. On all other compilers we're just checking that
247 // everything about SFINAE-enabled code will work, except of course
250 typename
boost::enable_if
<boost::is_same
<int,A0
>, int>::type
257 #if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580))
259 // Sun has problems with this syntax:
261 // template1< r* ( template2<x> ) >
263 // Workaround: factor template2<x> into a separate typedef
264 typedef boost::is_convertible
<boost::mpl::_
, std::string
> predicate
;
266 BOOST_PARAMETER_FUNCTION(
278 BOOST_PARAMETER_FUNCTION(
281 (name
, *(boost::is_convertible
<boost::mpl::_
, std::string
>))
289 #ifndef BOOST_NO_SFINAE
290 // On compilers that actually support SFINAE, add another overload
291 // that is an equally good match and can only be in the overload set
292 // when the others are not. This tests that the SFINAE is actually
293 // working. On all other compilers we're just checking that
294 // everything about SFINAE-enabled code will work, except of course
297 typename
boost::enable_if
<boost::is_same
<int,A0
>, int>::type
298 sfinae1(A0
const& a0
)
305 T
const& as_lvalue(T
const& x
)
312 udt(int foo
, int bar
)
321 BOOST_PARAMETER_FUNCTION((int), lazy_defaults
, tag
,
338 using namespace test
;
341 values(S("foo"), 1.f
, 2)
346 tester
= values(S("foo"), 1.f
, 2)
350 int index_lvalue
= 2;
353 tester
= values(S("foo"), 1.f
, 2)
356 , test::index
= index_lvalue
360 values(S("foo"), 1.f
, 2)
367 values(S("foo"), 1.f
, 2)
370 #if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
378 values(S("foo"), 1.f
, 2)
381 #if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
389 tester
= values(S("foo"), 1.f
, 2)
395 values(S("foo"), 1.f
, 2)
396 , S("foo"), test::index
= 2
400 values(S("foo"), 1.f
, 2)
405 tester
= values(S("foo"), 1.f
, 2)
410 values(S("foo"), 1.f
, 2)
415 tester
= values(S("foo"), 1.f
, 2)
419 class_
const& x_const
= x
;
422 values(S("foo"), 1.f
, 2)
427 tester
= values(S("foo"), 1.f
, 2)
432 values(S("foo"), 1.f
, 2)
437 tester
= values(S("foo"), 1.f
, 2)
442 tester
= values(S("foo"), 1.f
, 2)
447 values(S("foo"), 1.f
, 2)
452 tester
= values(S("foo"), 1.f
, 2)
456 #if ! defined(BOOST_NO_SFINAE) && ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
457 assert(sfinae("foo") == 1);
458 assert(sfinae(1) == 0);
460 # if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580))
461 // Sun actually eliminates the desired overload for some reason.
462 // Disabling this part of the test because SFINAE abilities are
463 // not the point of this test.
464 assert(sfinae1("foo") == 1);
467 assert(sfinae1(1) == 0);