is_copy_assignable.qbk 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. [/
  2. Copyright 2007 John Maddock.
  3. Copyright 2014 Ion Gaztanaga.
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt).
  7. ]
  8. [section:is_copy_assignable is_copy_assignable]
  9. template <class T>
  10. struct is_copy_assignable : public __tof {};
  11. __inherit If `T` is `CopyAssignable` (i.e. has an accessible explicit or implicit copy assignment operator),
  12. then inherits from __true_type, otherwise inherits from __false_type. Type `T`
  13. must be a complete type.
  14. In other words, inherits from __true_type only if copy assignment of `T` from `const T &` is not
  15. marked with `= delete`, `T` does not derives from `boost::noncopyable` and
  16. is not marked with `BOOST_MOVABLE_BUT_NOT_COPYABLE(T)`.
  17. __compat Requires the C++11 features `decltype` and SFINAE-expressions for full support.
  18. If your compiler does not support C++11 deleted functions (`= delete`) or does not support
  19. SFINAE for the deleted assignments, then derive your classes from `boost::noncopyable` or
  20. mark them with `BOOST_MOVABLE_BUT_NOT_COPYABLE(T)` to show that class is non-assignable.
  21. Trait does not care about access modifiers, so if you see errors like this:
  22. 'T::operator=(const T&)' is private
  23. boost/type_traits/is_copy_assignable.hpp:68:5: error: within this context
  24. then you are trying to call that macro for a structure with private assignment:
  25. struct T {
  26. // ...
  27. private:
  28. T &operator=(const T &);
  29. // ...
  30. };
  31. To fix that you must modify your structure, explicitly marking it as noncopyable (`= delete`,
  32. `boost::noncopyable` or `BOOST_MOVABLE_BUT_NOT_COPYABLE(T)`) or explicitly
  33. [link boost_typetraits.user_defined specializing the trait].
  34. __header ` #include <boost/type_traits/is_copy_assignable.hpp>` or ` #include <boost/type_traits.hpp>`
  35. [endsect]