has_trivial_assign.qbk 1.8 KB

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