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
16namespace 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
41int main() {
42 float f = 0;
43 double d = 0;
44 long double l = 0;
45
46 test::check_return_type<float>::equals(std::ldexp(x: f, exp: 0));
47 test::check_return_type<double>::equals(std::ldexp(x: d, exponent: 0));
48 test::check_return_type<long double>::equals(std::ldexp(x: l, exp: 0));
49
50 int dummy = 0;
51
52 test::check_return_type<float>::equals(std::frexp(x: f, exp: &dummy));
53 test::check_return_type<double>::equals(std::frexp(x: d, exponent: &dummy));
54 test::check_return_type<long double>::equals(std::frexp(x: l, exp: &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}
64

source code of boost/libs/container_hash/test/check_float_funcs.cpp