std::is_constructible, std::is_trivially_constructible, std::is_nothrow_constructible
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, class... Args> struct is_constructible; | (1) | (dal C++11) |
template<class T, class... Args> struct is_trivially_constructible; | (2) | (dal C++11) |
template<class T, class... Args> struct is_nothrow_constructible; | (3) | (dal C++11) |
Se il T obj(arg1, arg2, ... argN); espressione è ben formato, dato riferimenti rvalue a
2) Args...
come argomenti, fornisce l'elemento costante value
true uguali. Per qualsiasi altro tipo, è value
false.Original:
If the expression T obj(arg1, arg2, ... argN); is well-formed, given rvalue references to
Args...
as arguments, provides the member constant value
equal true. For any other type, 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.
uguale a 1), ma l'espressione di costruzione non richiede qualsiasi operazione che non è banale.
3) Original:
same as 1), but the constructor expression does 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 l'espressione costruttore è noexcept.
Original:
same as 1), but the constructor expression is 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 constructible from Args... , false altrimenti Original: true if T is constructible from Args... , 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]Esempio
#include <iostream>#include <type_traits> class Foo {int v1;double v2;public: Foo(int n): v1(n), v2(){} Foo(int n, double f)noexcept: v1(n), v2(f){}}; int main(){std::cout<<"Foo is ...\n"<<std::boolalpha<<"\tTrivially-constructible from const Foo&? "<< std::is_trivially_constructible<Foo, const Foo&>::value<<'\n'<<"\tTrivially-constructible from int? "<< std::is_trivially_constructible<Foo, int>::value<<'\n'<<"\tConstructible from int? "<< std::is_constructible<Foo, int>::value<<'\n'<<"\tNothrow-constructible from int? "<< std::is_nothrow_constructible<Foo, int>::value<<'\n'<<"\tNothrow-constructible from int and double? "<< std::is_nothrow_constructible<Foo, int, double>::value<<'\n';}
Output:
Foo is ... Trivially-constructible from const Foo&? true Trivially-constructible from int? false Constructible from int? true Nothrow-constructible from int? false Nothrow-constructible from int and double? true
[modifica]Vedi anche
Verifica se un tipo ha un costruttore di default Original: checks if a type has a default constructor 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 costruttore di copia Original: checks if a type has a copy constructor 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 costruttore mossa Original: checks if a type has a move constructor 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) | controlla se il tipo specificato supporta usi-allocatore di costruzione Original: checks if the specified type supports uses-allocator construction The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (classe template) |