user_defined.qbk 1.1 KB

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