]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/container_hash/test/check_float_funcs.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / container_hash / test / check_float_funcs.cpp
1
2 // Copyright 2012 Daniel James.
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 #if defined(__GNUC__)
7 // in type_traits/is_complete.hpp:47
8 #pragma GCC diagnostic ignored "-Wconversion"
9 #endif
10
11 #include <boost/static_assert.hpp>
12 #include <boost/type_traits/is_same.hpp>
13 #include <boost/type_traits/is_convertible.hpp>
14 #include <cmath>
15
16 namespace test
17 {
18 template <class T1>
19 struct check_return_type
20 {
21 template <class T2>
22 static void equals(T2)
23 {
24 BOOST_STATIC_ASSERT((boost::is_same<T1, T2>::value));
25 }
26
27 template <class T2>
28 static void equals_ref(T2&)
29 {
30 BOOST_STATIC_ASSERT((boost::is_same<T1, T2>::value));
31 }
32
33 template <class T2>
34 static void convertible(T2)
35 {
36 BOOST_STATIC_ASSERT((boost::is_convertible<T2, T1>::value));
37 }
38 };
39 }
40
41 int main() {
42 float f = 0;
43 double d = 0;
44 long double l = 0;
45
46 test::check_return_type<float>::equals(std::ldexp(f, 0));
47 test::check_return_type<double>::equals(std::ldexp(d, 0));
48 test::check_return_type<long double>::equals(std::ldexp(l, 0));
49
50 int dummy = 0;
51
52 test::check_return_type<float>::equals(std::frexp(f, &dummy));
53 test::check_return_type<double>::equals(std::frexp(d, &dummy));
54 test::check_return_type<long double>::equals(std::frexp(l, &dummy));
55
56 #if BOOST_HASH_USE_FPCLASSIFY
57
58 int (*fpc1)(float) = std::fpclassify;
59 int (*fpc2)(double) = std::fpclassify;
60 int (*fpc3)(long double) = std::fpclassify;
61
62 #endif
63 }