is_assignable.qbk 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. [/
  2. Copyright 2015 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:is_assignable is_assignable]
  8. template <class T, class U>
  9. struct is_assignable : public __tof {};
  10. __inherit If `std::declval<T>() = std::declval<U>()` then inherits from __true_type,
  11. otherwise from __false_type. Type `T` must be a complete type.
  12. Note that this trait is somewhat tricky to use correctly: for example:
  13. is_assignable<int, int>::value
  14. is `false` since `std::declval<int>()` is an ['xvalue] which can not be assigned to!
  15. If you're intention is to check for copy-assignment from some type U then use:
  16. is_assignable<T&, const U&>::value
  17. If you're intention is to check for move-assignment then use:
  18. is_assignable<T&, U&&>::value
  19. or simply:
  20. is_assignable<T&, U>::value
  21. __compat Requires the C++11 features `decltype` and SFINAE-expressions for full support.
  22. __header ` #include <boost/type_traits/is_assignable.hpp>` or ` #include <boost/type_traits.hpp>`
  23. [endsect]