]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/any/test/any_test.cpp
1 // Copyright Kevlin Henney, 2000, 2001. All rights reserved.
2 // Copyright Antony Polukhin, 2013-2022.
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 // what: unit tests for variant type boost::any
9 // who: contributed by Kevlin Henney
10 // when: July 2001, 2013, 2014
11 // where: tested with BCC 5.5, MSVC 6.0, and g++ 2.95
13 #include <boost/any.hpp>
15 #include "basic_test.hpp"
17 static const std::string
& returning_string1()
19 static const std::string
ret("foo");
23 static std::string
returning_string2()
25 static const std::string
ret("foo");
29 static void test_with_func()
32 s
= boost::any_cast
<std::string
>(returning_string1());
33 s
= boost::any_cast
<const std::string
&>(returning_string1());
35 s
= boost::any_cast
<std::string
>(returning_string2());
36 s
= boost::any_cast
<const std::string
&>(returning_string2());
38 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
39 #if !defined(__INTEL_COMPILER) && !defined(__ICL) && (!defined(_MSC_VER) || _MSC_VER != 1600)
40 // Intel compiler thinks that it must choose the `any_cast(const any&)` function
41 // instead of the `any_cast(const any&&)`.
42 // Bug was not reported because of missing premier support account + annoying
43 // registrations requirements.
47 // any.hpp(291) : error C2440: 'return' : cannot convert.
48 // Conversion loses qualifiers
49 // any_test.cpp(304) : see reference to function template instantiation
51 // This issue was fixed in MSVC-11.
53 s
= boost::any_cast
<std::string
&&>(returning_string1());
56 s
= boost::any_cast
<std::string
&&>(returning_string2());
63 return any_tests::basic_tests
<boost::any
>::run_tests();