std::is_copy_assignable, std::is_trivially_copy_assignable, std::is_nothrow_copy_assignable
Материал из cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Заголовочный файл <type_traits>
|
||
| template< class T > struct is_copy_assignable; |
(1) | (начиная с C++11) |
| template< class T > struct is_trivially_copy_assignable; |
(2) | (начиная с C++11) |
| template< class T > struct is_nothrow_copy_assignable; |
(3) | (начиная с C++11) |
Проверяет, является ли тип
2) CopyAssignable, т. е. имеет доступный явного или неявного копирования оператора присваивания. Если требование считается выполненным, член постоянной value равных true обеспечивается, в противном случае value является false.Original:
Checks whether a type is
CopyAssignable, i.e. has an accessible explicit or implicit copy assignment operator. If the requirement is met, a member constant value equal true is provided, otherwise value is false.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
То же, 1), но оценка копирования выражения присваивания не буду называть любой операции, которая не является тривиальной.
3) Original:
Same as 1), but evaluation of the copy-assignment expression will not call any operation that is not trivial.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
То же, 1), но оценки копирования выражения присваивания не буду называть любые операции, которые не noexcept.
Original:
Same as 1), but the evaluation of the copy-assignment expression will not call any operation that is not noexcept.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Содержание |
Унаследован от std::integral_constant
Member constants
| value [static] |
true если T is copy-assignable, false иначе Original: true if T is copy-assignable, false otherwise The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public static константа-член) |
Member functions
| operator bool |
преобразует объект в bool, возвращает value Original: converts the object to bool, returns value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public функция-член) |
Member types
| Type
Original: Type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
value_type
|
bool
|
type
|
std::integral_constant<bool, value> |
[править] Возможная реализация
template< class T> struct is_copy_assignable : std::is_assignable< typename std::add_lvalue_reference<T>::type, const typename std::add_lvalue_reference<T>::type> {}; template< class T> struct is_trivially_copy_assignable : std::is_trivially_assignable< typename std::add_lvalue_reference<T>::type, const typename std::add_lvalue_reference<T>::type> {}; template< class T> struct is_nothrow_copy_assignable : std::is_nothrow_assignable< typename std::add_lvalue_reference<T>::type, const typename std::add_lvalue_reference<T>::type> {}; |
[править] Пример
#include <iostream> #include <utility> #include <type_traits> struct Foo { int n; }; int main() { std::cout << std::boolalpha << "Foo is trivally copy-assignable? " << std::is_trivially_copy_assignable<Foo>::value << '\n' << "int[2] is copy-assignable? " << std::is_copy_assignable<int[2]>::value << '\n' << "int is nothrow copy-assignable? " << std::is_nothrow_copy_assignable<int>::value << '\n'; }
Вывод:
Foo is trivally copy-assignable? true int[2] is copy-assignable? false int is nothrow copy-assignable? true
[править] См. также
| (C++11) (C++11) (C++11) |
проверяет, является ли тип имеет оператор присваивания для конкретного аргумента Original: checks if a type has a assignment operator for a specific argument The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (шаблон класса) |
| (C++11) (C++11) (C++11) |
проверяет, является ли тип имеет оператор ход назначения Original: checks if a type has a move assignment operator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (шаблон класса) |