]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/convert/test/has_member.cpp
1 // Boost.Convert test and usage example
2 // Copyright (c) 2009-2016 Vladimir Batov.
3 // Use, modification and distribution are subject to the Boost Software License,
4 // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt.
8 #if defined(BOOST_CONVERT_INTEL_SFINAE_BROKEN) || defined(BOOST_CONVERT_MSVC_SFINAE_BROKEN)
9 int main(int, char const* []) { return 0; }
12 #include <boost/convert.hpp>
13 #include <boost/detail/lightweight_test.hpp>
17 //[has_member_declaration
18 namespace { namespace local
20 BOOST_DECLARE_HAS_MEMBER(has_begin
, begin
);
21 BOOST_DECLARE_HAS_MEMBER(has_funop
, operator());
24 //[has_member_classes_tested
25 namespace { namespace local
27 struct test01
{ int begin
; };
28 struct test02
{ char* begin() { return 0; } };
29 struct test22
{ void operator()() {} };
33 namespace { namespace local
38 int begin(int, int) { return 0; }
44 private: virtual char* begin() { return 0; }
48 virtual char* begin() { return 0; }
51 struct test06
: public test04
{};
52 struct test07
: private test04
{};
53 struct test08
: public test05
{};
54 struct test09
: private test05
{};
56 struct test11
{ int no_begin
; };
57 struct test12
{ char* no_begin() { return 0; } };
60 namespace { namespace local
62 struct test21
{ void zoo () {} };
63 struct test23
{ void operator() () const {} };
64 struct test24
{ int operator() (int) { return 0; } };
65 struct test25
{ int operator() (int) const { return 0; } };
66 struct test26
{ int operator() (int) const { return 0; } void operator() () const {} };
70 main(int, char const* [])
72 BOOST_TEST(local::has_begin
<local::test01
>::value
== true);
73 BOOST_TEST(local::has_begin
<local::test02
>::value
== true);
74 BOOST_TEST(local::has_begin
<local::test03
>::value
== true);
75 BOOST_TEST(local::has_begin
<local::test04
>::value
== true);
76 BOOST_TEST(local::has_begin
<local::test05
>::value
== true);
77 BOOST_TEST(local::has_begin
<local::test06
>::value
== true);
78 BOOST_TEST(local::has_begin
<local::test07
>::value
== true);
79 BOOST_TEST(local::has_begin
<local::test08
>::value
== true);
80 BOOST_TEST(local::has_begin
<local::test09
>::value
== true);
81 BOOST_TEST(local::has_begin
<std::string
>::value
== true);
82 BOOST_TEST(local::has_begin
<std::vector
<int> >::value
== true);
84 BOOST_TEST(local::has_begin
<local::test11
>::value
== false);
85 BOOST_TEST(local::has_begin
<local::test12
>::value
== false);
86 BOOST_TEST(local::has_begin
<std::iostream
>::value
== false);
89 BOOST_TEST(local::has_begin
<local::test01
>::value
== true);
90 BOOST_TEST(local::has_begin
<local::test02
>::value
== true);
91 BOOST_TEST(local::has_funop
<local::test22
>::value
== true);
94 BOOST_TEST(local::has_funop
<local::test21
>::value
== false);
95 BOOST_TEST(local::has_funop
<local::test22
>::value
== true);
96 BOOST_TEST(local::has_funop
<local::test23
>::value
== true);
97 BOOST_TEST(local::has_funop
<local::test24
>::value
== true);
98 BOOST_TEST(local::has_funop
<local::test25
>::value
== true);
99 BOOST_TEST(local::has_funop
<local::test26
>::value
== true);
101 return boost::report_errors();