has_trivial_destructor.qbk 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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:has_trivial_destructor has_trivial_destructor]
  8. template <class T>
  9. struct has_trivial_destructor : public __tof {};
  10. __inherit If T is a (possibly cv-qualified) type with a trivial destructor
  11. then inherits from __true_type, otherwise inherits from __false_type.
  12. If a type has a trivial destructor then the destructor has no effect:
  13. calls to the destructor can be safely omitted. Note that using meta-programming
  14. to omit a call to a single trivial-constructor call is of no benefit whatsoever.
  15. However, if loops and/or exception handling code can also be omitted, then some
  16. benefit in terms of code size and speed can be obtained.
  17. __compat Without some (as yet unspecified) help from the compiler,
  18. has_trivial_destructor will never report that a user-defined class or struct has a
  19. trivial destructor; this is always safe, if possibly sub-optimal.
  20. In addition, in order to correctly handle deleted or private destructors then
  21. support for C++11's `decltype` is required.
  22. Currently (June 2015) compilers more recent than Visual C++ 8, GCC-4.3, Greenhills 6.0,
  23. Intel-11.0, and Codegear have the necessary compiler __intrinsics to ensure that this
  24. trait "just works". You may also test to see if the necessary __intrinsics are available
  25. by checking to see if the macro `BOOST_HAS_TRIVIAL_DESTRUCTOR` is defined.
  26. __std_ref 12.4p3.
  27. __header ` #include <boost/type_traits/has_trivial_destructor.hpp>` or ` #include <boost/type_traits.hpp>`
  28. __examples
  29. [:`has_trivial_destructor<int>` inherits from `__true_type`.]
  30. [:`has_trivial_destructor<char*>::type` is the type `__true_type`.]
  31. [:`has_trivial_destructor<int (*)(long)>::value` is an integral constant
  32. expression that evaluates to /true/.]
  33. [:`has_trivial_destructor<MyClass>::value` is an integral constant
  34. expression that evaluates to /false/.]
  35. [:`has_trivial_destructor<T>::value_type` is the type `bool`.]
  36. [endsect]