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:integral_constant integral_constant] |
| 9 | template <class T, T val> |
| 10 | struct integral_constant |
| 11 | { |
| 12 | typedef integral_constant<T, val> type; |
| 13 | typedef T value_type; |
| 14 | static const T value = val; |
| 15 | constexpr operator T()const; |
| 16 | }; |
| 17 | |
| 18 | typedef integral_constant<bool, true> true_type; |
| 19 | typedef integral_constant<bool, false> false_type; |
| 20 | |
| 21 | Class template `integral_constant` is the common base class for all the value-based |
| 22 | type traits. The two typedef's `true_type` and `false_type` are provided for |
| 23 | convenience: most of the value traits are Boolean properties and so will inherit from |
| 24 | one of these. |
| 25 | |
| 26 | [endsect] |
| 27 | |