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_pod is_pod] |
| 9 | template <class T> |
| 10 | struct is_pod : public __tof {}; |
| 11 | |
| 12 | __inherit If T is a (possibly cv-qualified) POD type then inherits from __true_type, |
| 13 | otherwise inherits from __false_type. |
| 14 | |
| 15 | POD stands for "Plain old data". |
| 16 | Arithmetic types, and enumeration types, |
| 17 | a pointers and pointer to members are all PODs. Classes and unions can also |
| 18 | be POD's if they have no non-static data members that are of reference or |
| 19 | non-POD type, no user defined constructors, no user defined assignment |
| 20 | operators, no private or protected non-static data members, |
| 21 | no virtual functions and no base classes. Finally, a cv-qualified POD is |
| 22 | still a POD, as is an array of PODs. |
| 23 | |
| 24 | __std_ref 3.9p10 and 9p4 (Note that POD's are also aggregates, see 8.5.1). |
| 25 | |
| 26 | __compat Without some (as yet unspecified) help from the compiler, is_pod will |
| 27 | never report that a class or struct is a POD; this is always safe, |
| 28 | if possibly sub-optimal. |
| 29 | Currently (June 2015) compilers more recent than Visual C++ 8, Clang-3, GCC-4.3, Greenhills 6.0, |
| 30 | Intel-11.0, and Codegear have the necessary compiler __intrinsics to ensure that this |
| 31 | trait "just works". You may also test to see if the necessary __intrinsics are available |
| 32 | by checking to see if the macro `BOOST_IS_POD` is defined. |
| 33 | |
| 34 | |
| 35 | __header ` #include <boost/type_traits/is_pod.hpp>` or ` #include <boost/type_traits.hpp>` |
| 36 | |
| 37 | __examples |
| 38 | |
| 39 | [:`is_pod<int>` inherits from `__true_type`.] |
| 40 | |
| 41 | [:`is_pod<char*>::type` is the type `__true_type`.] |
| 42 | |
| 43 | [:`is_pod<int (*)(long)>::value` is an integral constant |
| 44 | expression that evaluates to /true/.] |
| 45 | |
| 46 | [:`is_pod<MyClass>::value` is an integral constant |
| 47 | expression that evaluates to /false/.] |
| 48 | |
| 49 | [:`is_pod<T>::value_type` is the type `bool`.] |
| 50 | |
| 51 | [endsect] |
| 52 | |