Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame^] | 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 | #include <boost/static_assert.hpp> |
| 7 | #include <boost/type_traits/is_same.hpp> |
| 8 | #include <boost/type_traits/is_convertible.hpp> |
| 9 | #include <cmath> |
| 10 | |
| 11 | namespace test |
| 12 | { |
| 13 | template <class T1> |
| 14 | struct check_return_type |
| 15 | { |
| 16 | template <class T2> |
| 17 | static void equals(T2) |
| 18 | { |
| 19 | BOOST_STATIC_ASSERT((ndnboost::is_same<T1, T2>::value)); |
| 20 | } |
| 21 | |
| 22 | template <class T2> |
| 23 | static void equals_ref(T2&) |
| 24 | { |
| 25 | BOOST_STATIC_ASSERT((ndnboost::is_same<T1, T2>::value)); |
| 26 | } |
| 27 | |
| 28 | template <class T2> |
| 29 | static void convertible(T2) |
| 30 | { |
| 31 | BOOST_STATIC_ASSERT((ndnboost::is_convertible<T2, T1>::value)); |
| 32 | } |
| 33 | }; |
| 34 | } |
| 35 | |
| 36 | int main() { |
| 37 | float f = 0; |
| 38 | double d = 0; |
| 39 | long double l = 0; |
| 40 | |
| 41 | test::check_return_type<float>::equals(std::ldexp(f, 0)); |
| 42 | test::check_return_type<double>::equals(std::ldexp(d, 0)); |
| 43 | test::check_return_type<long double>::equals(std::ldexp(l, 0)); |
| 44 | |
| 45 | int dummy = 0; |
| 46 | |
| 47 | test::check_return_type<float>::equals(std::frexp(f, &dummy)); |
| 48 | test::check_return_type<double>::equals(std::frexp(d, &dummy)); |
| 49 | test::check_return_type<long double>::equals(std::frexp(l, &dummy)); |
| 50 | |
| 51 | #if BOOST_HASH_USE_FPCLASSIFY |
| 52 | |
| 53 | int (*fpc1)(float) = std::fpclassify; |
| 54 | int (*fpc2)(double) = std::fpclassify; |
| 55 | int (*fpc3)(long double) = std::fpclassify; |
| 56 | |
| 57 | #endif |
| 58 | } |