forked from boostorg/type_traits
is_copy_assignable implementation added. It needs C++11 support to work reliable.
This commit is contained in:
1 parent
bbcfff0278
commit
cf18d2bbac
5 files changed
+423
No files matched your search
@@ -0,0 +1,51 @@
|
||||
[/
|
||||
Copyright 2007 John Maddock.
|
||||
Copyright 2014 Ion Gaztanaga.
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt).
|
||||
]
|
||||
|
||||
[section:is_copy_assignable is_copy_assignable]
|
||||
|
||||
template <class T>
|
||||
struct is_copy_assignable : public __tof {};
|
||||
|
||||
__inherit If `T` is `CopyAssignable` (i.e. has an accessible explicit or implicit copy assignment operator),
|
||||
then inherits from __true_type, otherwise inherits from __false_type. Type `T`
|
||||
must be a complete type.
|
||||
|
||||
In other words, inherits from __true_type only if copy assignment of `T` from `const T &` is not
|
||||
marked with `= delete`, `T` does not derives from `boost::noncopyable` and
|
||||
is not marked with `BOOST_MOVABLE_BUT_NOT_COPYABLE(T)`.
|
||||
|
||||
__compat If the compiler does not support partial-specialization of class
|
||||
templates, then this template can not be used.
|
||||
|
||||
If your compiler does not support C++11 deleted functions (`= delete`) or does not support
|
||||
SFINAE for the deleted assignments, then derive your classes from `boost::noncopyable` or
|
||||
mark them with `BOOST_MOVABLE_BUT_NOT_COPYABLE(T)` to show that class is non-assignable.
|
||||
|
||||
Trait does not care about access modifiers, so if you see errors like this:
|
||||
|
||||
'T::operator=(const T&)' is private
|
||||
boost/type_traits/is_copy_assignable.hpp:68:5: error: within this context
|
||||
|
||||
then you are trying to call that macro for a structure with private assignment:
|
||||
|
||||
struct T {
|
||||
// ...
|
||||
private:
|
||||
T &operator=(const T &);
|
||||
// ...
|
||||
};
|
||||
|
||||
To fix that you must modify your structure, explicitly marking it as noncopyable (`= delete`,
|
||||
`boost::noncopyable` or `BOOST_MOVABLE_BUT_NOT_COPYABLE(T)`) or explicitly
|
||||
[link boost_typetraits.user_defined specializing the trait].
|
||||
|
||||
|
||||
__header ` #include <boost/type_traits/is_copy_assignable.hpp>` or ` #include <boost/type_traits.hpp>`
|
||||
|
||||
[endsect]
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
[def __is_empty [link boost_typetraits.reference.is_empty is_empty]]
|
||||
[def __is_const [link boost_typetraits.reference.is_const is_const]]
|
||||
[def __is_copy_constructible [link boost_typetraits.reference.is_copy_constructible is_copy_constructible]]
|
||||
[def __is_copy_assignable [link boost_typetraits.reference.is_copy_assignable is_copy_assignable]]
|
||||
[def __is_volatile [link boost_typetraits.reference.is_volatile is_volatile]]
|
||||
[def __is_abstract [link boost_typetraits.reference.is_abstract is_abstract]]
|
||||
[def __is_polymorphic [link boost_typetraits.reference.is_polymorphic is_polymorphic]]
|
||||
|
||||
Reference in new issue
Block a user