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:is_empty is_empty] |
| 9 | template <class T> |
| 10 | struct is_empty : public __tof {}; |
| 11 | |
| 12 | __inherit If T is an empty class type (and not a union type) then inherits from __true_type, |
| 13 | otherwise inherits from __false_type. |
| 14 | |
| 15 | __std_ref 10p5. |
| 16 | |
| 17 | __header ` #include <boost/type_traits/is_empty.hpp>` or ` #include <boost/type_traits.hpp>` |
| 18 | |
| 19 | __compat In order to correctly detect empty classes this trait relies on either: |
| 20 | |
| 21 | * the compiler implementing zero sized empty base classes, or |
| 22 | * the compiler providing __intrinsics to detect empty classes - this latter case can be tested for |
| 23 | by checking to see if the macro BOOST_IS_EMPTY is defined. |
| 24 | |
| 25 | Can not be used with incomplete types. |
| 26 | |
| 27 | __examples |
| 28 | |
| 29 | [:Given: `struct empty_class {};` ] |
| 30 | |
| 31 | [:`is_empty<empty_class>` inherits from `__true_type`.] |
| 32 | |
| 33 | [:`is_empty<empty_class const>::type` is the type `__true_type`.] |
| 34 | |
| 35 | [:`is_empty<empty_class>::value` is an integral constant |
| 36 | expression that evaluates to /true/.] |
| 37 | |
| 38 | [:`is_empty<T>::value_type` is the type `bool`.] |
| 39 | |
| 40 | [endsect] |
| 41 | |