std::is_copy_assignable, std::is_trivially_copy_assignable, std::is_nothrow_copy_assignable
Da cppreference.com.
![]() | Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate. La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
Elemento definito nell'header <type_traits> | ||
template<class T > struct is_copy_assignable; | (1) | (dal C++11) |
template<class T > struct is_trivially_copy_assignable; | (2) | (dal C++11) |
template<class T > struct is_nothrow_copy_assignable; | (3) | (dal C++11) |
Verifica se un tipo è
2) CopyAssignable
, cioè ha un accesso esplicito o implicito operatore di assegnamento per copia. Se la condizione è soddisfatta, un membro costante value
true parità è previsto, in caso contrario è 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.
Come 1), ma la valutazione della copia-assegnazione espressione non chiamerà qualsiasi operazione che non è banale.
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.
Uguale a 1), ma la valutazione della copia-assegnazione espressione non chiamerà qualsiasi operazione che non è 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.
Indice |
Inherited from std::integral_constant
Member constants
value [statico] | true se T is copy-assignable, false altrimenti 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. (pubblico membro statico costante) |
Member functions
operator bool | converte l'oggetto in bool, restituisce 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. (metodo pubblico) |
Member types
Tipo 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> |
[modifica]Possibile implementazione
template<class T>struct is_copy_assignable :std::is_assignable<typenamestd::add_lvalue_reference<T>::type, consttypenamestd::add_lvalue_reference<T>::type>{}; template<class T>struct is_trivially_copy_assignable :std::is_trivially_assignable<typenamestd::add_lvalue_reference<T>::type, consttypenamestd::add_lvalue_reference<T>::type>{}; template<class T>struct is_nothrow_copy_assignable :std::is_nothrow_assignable<typenamestd::add_lvalue_reference<T>::type, consttypenamestd::add_lvalue_reference<T>::type>{}; |
[modifica]Esempio
#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';}
Output:
Foo is trivally copy-assignable? true int[2] is copy-assignable? false int is nothrow copy-assignable? true
[modifica]Vedi anche
(C++11) (C++11) (C++11) | Verifica se un tipo ha un operatore di assegnazione per un argomento specifico 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. (classe template) |
(C++11) (C++11) (C++11) | Verifica se un tipo ha un operatore di assegnamento mossa 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. (classe template) |