std::is_nothrow_constructible in C++ with Examples Last Updated : 12 Jun, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The std::is_nothrow_constructible template of C++ STL is present in the <type_traits> header file. The std::is_nothrow_constructible template of C++ STL is used to check whether the given type T is constructible type with the set of arguments or not and this is known for not to throw any exception. It return the boolean value true if T is of constructible type, otherwise return false. Header File: #include<type_traits> Template Class: template< class T, class... Args > struct is_nothrow_constructible; Syntax: std::is_nothrow_constructible<T, Args..>::value Parameter: The template std::is_nothrow_constructible accepts the following parameters: T: It represent a data type. Args: It represent the list of data type T. Return Value: The template std::is_nothrow_constructible returns a boolean variable as shown below: True: If the type T is constructible from Args. False: If the type T is not constructible from Args. Below is the program to demonstrate std::is_nothrow_constructible in C++: Program 1: CPP // C++ program to illustrate // std::is_nothrow_constructible #include <bits/stdc++.h> #include <type_traits> using namespace std; // Declare structures struct X { }; struct Y { Y() {} Y(X&) noexcept {} }; struct Z { int n; Z() = default; }; // Driver Code int main() { cout << boolalpha; cout << "int is_nothrow_constructible? " << is_nothrow_constructible<int>::value << endl; cout << "X() is is_nothrow_constructible? " << is_nothrow_constructible<X>::value << endl; cout << "Y(X) is is_nothrow_constructible? " << is_nothrow_constructible<Y, X>::value << endl; cout << "Z() is is_nothrow_constructible? " << is_nothrow_constructible<Z>::value << endl; return 0; } Output: int is_nothrow_constructible? true X() is is_nothrow_constructible? true Y(X) is is_nothrow_constructible? false Z() is is_nothrow_constructible? true Program 2: CPP // C++ program to illustrate // std::is_nothrow_constructible #include <bits/stdc++.h> #include <type_traits> using namespace std; // Class GfG class GfG { int v1; float v2; public: GfG(int n) : v1(n), v2() { } GfG(int n, double f) noexcept : v1(n), v2(f) {} }; // Declare Structure struct X { int n; X() = default; }; // Driver Code int main() { cout << boolalpha; cout << "GfG is Nothrow-constructible from int? " << is_nothrow_constructible<GfG, int>::value << '\n'; cout << "GfG is Nothrow-constructible from int and float? " << is_nothrow_constructible<GfG, int, float>::value << '\n'; cout << "GfG is Nothrow-constructible from struct X? " << is_nothrow_constructible<GfG, X>::value << '\n'; } Output: GfG is Nothrow-constructible from int? false GfG is Nothrow-constructible from int and float? true GfG is Nothrow-constructible from struct X? false Reference: http://www.cplusplus.com/reference/type_traits/is_nothrow_constructible/ Comment More infoAdvertise with us Next Article std::is_nothrow_destructible in C++ with Examples B bansal_rtk_ Follow Improve Article Tags : Misc C++ CPP-Functions Practice Tags : CPPMisc Similar Reads std::is_nothrow_copy_constructible in C++ with Examples The std::is_nothrow_copy_constructible template of C++ STL is present in the <type_traits> header file. The std::is_nothrow_copy_constructible template of C++ STL is used to check whether T is copy constructible type or not and this is known for not to throw any exception. It return the boolea 2 min read std::is_nothrow_destructible in C++ with Examples The std::is_nothrow_destructible template of C++ STL is present in the <type_traits> header file. The std::is_nothrow_denstructible template of C++ STL is used to check whether T is destructible type or not and this is known for not to throw any exception. It return the boolean value true if T 3 min read std::is_nothrow_move_constructible in C++ with Example The std::is_nothrow_move_constructible template of C++ STL is present in the <type_traits> header file. The std::is_nothrow_move_constructible template of C++ STL is used to check whether the given type T T is move constructibe or not and this is known for not to throw any exception. It return 2 min read std::is_nothrow_default_constructible in C++ with Examples The std::is_nothrow_default_constructible template of C++ STL is present in the <type_traits> header file. The std::is_nothrow_default_constructible template of C++ STL is used to check whether the given type T is default constructible type or not and this is known for not to throw any excepti 2 min read std::is_move_constructible in C++ with Examples The std::is_move_constructible template of C++ STL is present in the <type_traits> header file. The std::is_move_constructible template of C++ STL is used to check whether the T is move constructible (that can be constructed from an rvalue reference of its type) or not. It returns the boolean 2 min read std::is_copy_constructible in C++ with Examples The std::is_copy_constructible template of C++ STL is present in the <type_traits> header file. The std::is_copy_constructible template of C++ STL is used to check whether the T is copy constructible or not. It return the boolean value true if T is copy constructible type, Otherwise return fal 2 min read Like