has_trivial_copy.qbk 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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_copy has_trivial_copy]
  8. template <class T>
  9. struct has_trivial_copy : public __tof {};
  10. template <class T>
  11. struct has_trivial_copy_constructor : public __tof {};
  12. __inherit If T is a (possibly cv-qualified) type with a trivial copy-constructor
  13. then inherits from __true_type, otherwise inherits from __false_type.
  14. These two traits are synonyms for each other.
  15. If a type has a trivial copy-constructor then the constructor has the same effect
  16. as copying the bits of one object to the other:
  17. calls to the constructor can be safely replaced with a call to `memcpy`.
  18. __compat Without some (as yet unspecified) help from the compiler,
  19. has_trivial_copy will never report that a user-defined class or struct has a
  20. trivial constructor; this is always safe, if possibly sub-optimal.
  21. In addition, in order to correctly handle deleted or private copy-constructors
  22. then C++11's `dectype` is required.
  23. Currently (May 2015) compilers more recent than Visual C++ 8, GCC-4.3, Greenhills 6.0,
  24. Intel-11.0, and Codegear have the necessary compiler __intrinsics to ensure that this
  25. trait "just works". You may also test to see if the necessary __intrinsics are available
  26. by checking to see if the macro `BOOST_HAS_TRIVIAL_COPY` is defined.
  27. __std_ref 12.8p6.
  28. __header ` #include <boost/type_traits/has_trivial_copy.hpp>` or ` #include <boost/type_traits.hpp>`
  29. __examples
  30. [:`has_trivial_copy<int>` inherits from `__true_type`.]
  31. [:`has_trivial_copy<char*>::type` is the type `__true_type`.]
  32. [:`has_trivial_copy<int (*)(long)>::value` is an integral constant
  33. expression that evaluates to /true/.]
  34. [:`has_trivial_copy<MyClass>::value` is an integral constant
  35. expression that evaluates to /false/.]
  36. [:`has_trivial_copy<T>::value_type` is the type `bool`.]
  37. [endsect]