]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/conversion/test/implicit_cast.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / conversion / test / implicit_cast.cpp
CommitLineData
7c673cae
FG
1// Copyright David Abrahams 2003.
2// Distributed under the Boost Software License, Version 1.0. (See
3// accompanying file LICENSE_1_0.txt or copy at
4// http://www.boost.org/LICENSE_1_0.txt)
5
6#include <boost/implicit_cast.hpp>
7#include <boost/detail/lightweight_test.hpp>
8#include <boost/type.hpp>
9using boost::implicit_cast;
10using boost::type;
11
12template <class T>
13type<T> check_return(T) { return type<T>(); }
14
15struct foo
16{
17 foo(char const*) {}
18 operator long() const { return 0; }
19};
20
21typedef type<long> long_type;
22typedef type<foo> foo_type;
23
24int main()
25{
26 type<long> x = check_return(boost::implicit_cast<long>(1));
27 BOOST_TEST(boost::implicit_cast<long>(1) == 1L);
28
29 type<foo> f = check_return(boost::implicit_cast<foo>("hello"));
30 type<long> z = check_return(boost::implicit_cast<long>(foo("hello")));
31
32 // warning suppression:
33 (void)x;
34 (void)f;
35 (void)z;
36
1e59de90
TL
37
38 BOOST_CONSTEXPR long value = boost::implicit_cast<long>(42);
39 BOOST_TEST(value == 42L);
40
7c673cae
FG
41 return boost::report_errors();
42}