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:promote promote] |
| 9 | |
| 10 | template <class T> |
| 11 | struct promote |
| 12 | { |
| 13 | typedef __below type; |
| 14 | }; |
| 15 | |
| 16 | template <class T> using promote_t = typename promote<T>::type; // C++11 and above |
| 17 | |
| 18 | __type If integral or floating point promotion can be applied to an rvalue |
| 19 | of type `T`, then applies integral and floating point promotions to `T` and |
| 20 | keeps cv-qualifiers of `T`, otherwise leaves `T` unchanged. See also |
| 21 | __integral_promotion and __floating_point_promotion. |
| 22 | |
| 23 | __std_ref 4.5 except 4.5/3 (integral bit-field) and 4.6. |
| 24 | |
| 25 | [all_compilers] |
| 26 | |
| 27 | __header ` #include <boost/type_traits/promote.hpp>` or ` #include <boost/type_traits.hpp>` |
| 28 | |
| 29 | [table Examples |
| 30 | |
| 31 | [ [Expression] [Result Type]] |
| 32 | |
| 33 | [[`promote<short volatile>::type`][`int volatile`]] |
| 34 | |
| 35 | [[`promote<float const>::type`][`double const`]] |
| 36 | |
| 37 | [[`promote<short&>::type`][`short&`]] |
| 38 | |
| 39 | ] |
| 40 | |
| 41 | [endsect] |
| 42 | |