Brian Silverman | 4a2409e | 2018-08-04 23:24:02 -0700 | [diff] [blame^] | 1 | [/ |
| 2 | Copyright 2007 John Maddock. |
| 3 | Distributed under the Boost Software License, Version 1.0. |
| 4 | (See accompanying file LICENSE_1_0.txt or copy at |
| 5 | http://www.boost.org/LICENSE_1_0.txt). |
| 6 | ] |
| 7 | |
| 8 | [section:floating_point_promotion floating_point_promotion] |
| 9 | |
| 10 | template <class T> |
| 11 | struct floating_point_promotion |
| 12 | { |
| 13 | typedef __below type; |
| 14 | }; |
| 15 | |
| 16 | template <class T> using floating_point_promotion_t = typename floating_point_promotion<T>::type; // C++11 and above |
| 17 | |
| 18 | __type If floating point promotion can be applied to an rvalue of type `T`, |
| 19 | then applies floating point promotion to `T` and keeps cv-qualifiers of `T`, |
| 20 | otherwise leaves `T` unchanged. |
| 21 | |
| 22 | __std_ref 4.6. |
| 23 | |
| 24 | __header ` #include <boost/type_traits/floating_point_promotion.hpp>` or ` #include <boost/type_traits.hpp>` |
| 25 | |
| 26 | [table Examples |
| 27 | |
| 28 | [ [Expression] [Result Type]] |
| 29 | |
| 30 | [[`floating_point_promotion<float const>::type`][`double const`]] |
| 31 | |
| 32 | [[`floating_point_promotion<float&>::type`][`float&`]] |
| 33 | |
| 34 | [[`floating_point_promotion<short>::type`][`short`]] |
| 35 | |
| 36 | ] |
| 37 | |
| 38 | [all_compilers] |
| 39 | |
| 40 | [endsect] |
| 41 | |