std::is_nothrow_assignable in C++ with Examples Last Updated : 12 Jun, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The std::is_nothrow_assignable template of C++ STL is present in the <type_traits> header file. The std::is_nothrow_assignable template of C++ STL is used to check whether A is type assignable to B or not and this is known for not to throw any exception. It return the boolean value true if A is type assignable to B, Otherwise return false. Header File: #include<type_traits> Template Class: template< class A, class B > struct is_nothrow_assignable; Syntax: std::is_assignable<A, B>::value Parameters: The template std::is_assignable accepts the following parameters: A: It represents the parameter in which parameter B is implicitly assign. B: It represents the parameter type assignable to A. Return Value: The template std::is_assignable returns a boolean variable as shown below: True: If the type A is assignable to type B. False: If the type A is not assignable to type B. Below is the program to demonstrate std::is_nothrow_assignable template in C++: Program: CPP // C++ program to illustrate // std::is_nothrow_assignable #include <bits/stdc++.h> #include <type_traits> using namespace std; // Declare structures struct A { }; struct B { B& operator=(const A&) noexcept { return *this; } B& operator=(const B&) { return *this; } }; // Declare classes class GfG { }; class gfg { }; enum class AB : int { x, y, z }; // Driver Code int main() { cout << boolalpha; // Check if int& is assignable to // double or not cout << "is int = double? " << is_nothrow_assignable<int&, double>::value << endl; // Check if struct A is assignable to // srtuct A or not cout << "is struct A = struct A? " << is_nothrow_assignable<A, A>::value << endl; // Check if struct B is assignable to // srtuct A or not cout << "is class B = class A? " << is_nothrow_assignable<B, A>::value << endl; // Check if struct B is assignable to // srtuct B or not cout << "is class B = class B? " << is_nothrow_assignable<B, B>::value << endl; // Check if enum class AB is assignable // from class gfg or not cout << "is class AB = class gfg? " << is_nothrow_assignable<AB, gfg>::value << endl; // Check if class GfG assignable to // class gfg or not cout << "is class Gfg = class gfg? " << is_nothrow_assignable<GfG, gfg>::value << endl; return 0; } Output: is int = double? true is struct A = struct A? true is class B = class A? true is class B = class B? false is class AB = class gfg? false is class Gfg = class gfg? false Reference: http://www.cplusplus.com/reference/type_traits/is_nothrow_assignable/ Comment More infoAdvertise with us Next Article std::is_nothrow_assignable in C++ with Examples B bansal_rtk_ Follow Improve Article Tags : Misc C++ CPP-Functions Practice Tags : CPPMisc Similar Reads std::is_nothrow_copy_assignable in C++ with Examples The std::is_nothrow_copy_assignable template of C++ STL is present in the <type_traits> header file. The std::is_nothrow_copy_assignable template of C++ STL is used to check whether T is copy assignable type or not and this is known for not to throw any exception. It returns the boolean value 2 min read std::is_copy_assignable in C++ with Examples The std::is_copy_assignable template of C++ STL is present in the <type_traits> header file. The std::is_copy_assignable template of C++ STL is used to check whether the T is copy assignable or not. It return the boolean value true if T is copy assignable type, otherwise return false. Header F 2 min read std::is_move_assignable C++ with Examples The std::is_move_assignable template of C++ STL is present in the <type_traits> header file. The std::is_move_assignable template of C++ STL is used to check whether the T is a move assignable type(that can be assigned an rvalue reference of the same type) or not. It return the boolean value t 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_assignable template in C++ with Examples The std::is_assignable template of C++ STL is present in the <type_traits> header file. The std::is_assignable template of C++ STL is used to check whether a value of B type can be assigned to a A. It returns the boolean value either true or false. Below is the syntax for the same: Header File 2 min read Like