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:user_defined User Defined Specializations] |
| 9 | |
| 10 | Occationally the end user may need to provide their own specialization |
| 11 | for one of the type traits - typically where intrinsic compiler support |
| 12 | is required to implement a specific trait fully. |
| 13 | These specializations should derive from boost::__true_type or boost::__false_type |
| 14 | as appropriate: |
| 15 | |
| 16 | #include <boost/type_traits/is_pod.hpp> |
| 17 | #include <boost/type_traits/is_class.hpp> |
| 18 | #include <boost/type_traits/is_union.hpp> |
| 19 | |
| 20 | struct my_pod{}; |
| 21 | struct my_union |
| 22 | { |
| 23 | char c; |
| 24 | int i; |
| 25 | }; |
| 26 | |
| 27 | namespace boost |
| 28 | { |
| 29 | template<> |
| 30 | struct __is_pod<my_pod> : public __true_type{}; |
| 31 | |
| 32 | template<> |
| 33 | struct __is_pod<my_union> : public __true_type{}; |
| 34 | |
| 35 | template<> |
| 36 | struct __is_union<my_union> : public __true_type{}; |
| 37 | |
| 38 | template<> |
| 39 | struct __is_class<my_union> : public __false_type{}; |
| 40 | } |
| 41 | |
| 42 | [endsect] |
| 43 | |