intrinsics.qbk 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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:intrinsics Support for Compiler Intrinsics]
  8. There are some traits that can not be implemented within the current C++ language:
  9. to make these traits "just work" with user defined types, some kind of additional
  10. help from the compiler is required. Currently (April 2008) Visual C++ 8 and 9,
  11. GNU GCC 4.3 and MWCW 9 provide at least some of the the necessary intrinsics,
  12. and other compilers will no doubt follow in due course.
  13. The Following traits classes always need compiler support to do the right thing
  14. for all types
  15. (but all have safe fallback positions if this support is unavailable):
  16. * __is_final
  17. * __is_union
  18. * __is_pod
  19. * __is_nothrow_move_assignable
  20. * __is_nothrow_move_constructible
  21. * __has_trivial_constructor
  22. * __has_trivial_copy
  23. * __has_trivial_move_constructor
  24. * __has_trivial_assign
  25. * __has_trivial_move_assign
  26. * __has_trivial_destructor
  27. * __has_nothrow_constructor
  28. * __has_nothrow_copy
  29. * __has_nothrow_assign
  30. * __has_virtual_destructor
  31. The following traits classes can't be portably implemented in the C++ language,
  32. although in practice, the implementations do in fact do the right thing on all
  33. the compilers we know about:
  34. * __is_empty
  35. * __is_polymorphic
  36. * __is_virtual_base_of
  37. The following traits classes are dependent on one or more of the above:
  38. * __is_class
  39. * __is_stateless
  40. The hooks for compiler-intrinsic support are defined in
  41. [@../../../../boost/type_traits/intrinsics.hpp boost/type_traits/intrinsics.hpp], adding support for new compilers is simply
  42. a matter of defining one of more of the following macros:
  43. [table Macros for Compiler Intrinsics
  44. [[BOOST_ALIGNMENT_OF(T)][Should evaluate to the alignment requirements of type T]]
  45. [[BOOST_IS_ABSTRACT(T)][Should evaluate to true if T is an abstract type]]
  46. [[BOOST_IS_BASE_OF(T,U)][Should evaluate to true if T is a base class of U]]
  47. [[BOOST_IS_CLASS(T)][Should evaluate to true if T is a class type]]
  48. [[BOOST_IS_CONVERTIBLE(T,U)][Should evaluate to true if T is convertible to U]]
  49. [[BOOST_IS_EMPTY(T)][Should evaluate to true if T is an empty struct or union]]
  50. [[BOOST_IS_ENUM(T)][Should evaluate to true is T is an enum]]
  51. [[BOOST_IS_FINAL(T)][Should evaluate to true if T is a class type declared with the final specifier]]
  52. [[BOOST_IS_NOTHROW_MOVE_ASSIGN(T)][Should evaluate to true T has a non-throwing move assign operator.]]
  53. [[BOOST_IS_NOTHROW_MOVE_CONSTRUCT(T)][Should evaluate to true T has a non-throwing move constructor.]]
  54. [[BOOST_IS_POLYMORPHIC(T)][Should evaluate to true if T is a polymorphic type]]
  55. [[BOOST_IS_POD(T)][Should evaluate to true if T is a POD type]]
  56. [[BOOST_IS_UNION(T)][Should evaluate to true if T is a union type]]
  57. [[BOOST_HAS_NOTHROW_ASSIGN(T)][Should evaluate to true if `T t, u; t = u` can not throw]]
  58. [[BOOST_HAS_NOTHROW_CONSTRUCTOR(T)][Should evaluate to true if `T x;` can not throw]]
  59. [[BOOST_HAS_NOTHROW_COPY(T)][Should evaluate to true if `T(t)` can not throw]]
  60. [[BOOST_HAS_TRIVIAL_ASSIGN(T)][Should evaluate to true if T has a trivial assignment operator (and can therefore be replaced by a call to memcpy)]]
  61. [[BOOST_HAS_TRIVIAL_CONSTRUCTOR(T)][Should evaluate to true if the default constructor for T is trivial (i.e. has no effect)]]
  62. [[BOOST_HAS_TRIVIAL_COPY(T)][Should evaluate to true if T has a trivial copy constructor (and can therefore be replaced by a call to memcpy)]]
  63. [[BOOST_HAS_TRIVIAL_DESTRUCTOR(T)][Should evaluate to true if T has a trivial destructor (i.e. ~T() has no effect)]]
  64. [[BOOST_HAS_TRIVIAL_MOVE_CONSTRUCTOR(T)][Should evaluate to true if T has a trivial move constructor (and can therefore be replaced by a call to memcpy)]]
  65. [[BOOST_HAS_TRIVIAL_MOVE_ASSIGN(T)][Should evaluate to true if T has a trivial move assignment operator (and can therefore be replaced by a call to memcpy)]]
  66. [[BOOST_HAS_VIRTUAL_DESTRUCTOR(T)][Should evaluate to true T has a virtual destructor]]
  67. ]
  68. [endsect]