std::is_trivially_default_constructible in C++ with Example Last Updated : 15 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The std::is_trivially_default_constructible template of C++ STL is present in the <type_traits> header file. The std::is_trivially_default_constructible template of C++ STL is used to check whether T is trivially default constructible type or not. It return the boolean value true if T is trivially default constructible type, otherwise return false. Header File: #include<type_traits> Template Class: template< class T > struct is_default_constructible; Syntax: std::is_trivially_default_constructible<T>::value Parameter: The template std::is_trivially_default_constructible accepts a single parameter T(Trait class) to check whether T is trivially default constructible type or not. Return Value: The template std::is_trivially_default_constructible returns a boolean variable as shown below: True: If the type T is a trivially default constructible. False: If the type T is not a trivially default constructible. Below is the program to demonstrate std::is_trivially_default_constructible in C++: Program 1: CPP // C++ program to demonstrate // std::is_trivially_default_constructible #include <iostream> #include <type_traits> using namespace std; // Declaration of classes class A { }; class B { B() {} }; enum class C : int { x, y, z }; class D { int v1; double v2; public: D(int n) : v1(n), v2() { } D(int n, double f) noexcept : v1(n), v2(f) {} }; int main() { cout << boolalpha; // Check if int is trivially // default constructible or not cout << "int: " << is_trivially_default_constructible<int>::value << endl; // Check if class A is trivially // default constructible or not cout << "class A: " << is_trivially_default_constructible<A>::value << endl; // Check if class B is trivially // default constructible or not cout << "class B: " << is_trivially_default_constructible<B>::value << endl; // Check if enum class C is trivially // default constructible or not cout << "enum class C: " << is_trivially_default_constructible<C>::value << endl; // Check if class D is trivially // default constructible or not std::cout << "class D: " << is_trivially_default_constructible<D>::value << endl; return 0; } Output: int: true class A: true class B: false enum class C: true class D: false Program 2: CPP // C++ program to demonstrate // std::is_trivially_default_constructible #include <iostream> #include <type_traits> using namespace std; // Declare structures struct Ex1 { Ex1() {} Ex1(Ex1&&) { cout << "Throwing move constructor!"; } Ex1(const Ex1&) { cout << "Throwing copy constructor!"; } }; struct Ex2 { Ex2() {} Ex2(Ex2&&) noexcept { cout << "Non-throwing move constructor!"; } Ex2(const Ex2&) noexcept { cout << "Non-throwing copy constructor!"; } }; // Driver Code int main() { cout << boolalpha; // Check if struct Ex1 is default // constructible or not cout << "Ex1 is default-constructible? " << is_trivially_default_constructible<Ex1>::value << '\n'; // Check if struct Ex1 is trivially // defaultconstructible or not cout << "Ex1 is trivially default-constructible? " << is_trivially_default_constructible<Ex1>::value << '\n'; // Check if struct Ex2 is trivially // defaultconstructible or not cout << "Ex2 is trivially default-constructible? " << is_trivially_default_constructible<Ex2>::value << '\n'; } Output: Ex1 is default-constructible? false Ex1 is trivially default-constructible? false Ex2 is trivially default-constructible? false Reference: https://cplusplus.com/reference/type_traits/is_trivially_default_constructible/ Comment More infoAdvertise with us Next Article std::is_default_constructible in C++ with Examples B bansal_rtk_ Follow Improve Article Tags : Misc C++ CPP-Functions Practice Tags : CPPMisc Similar Reads std::is_trivially_constructible in C++ with Examples The std::is_trivially_constructible template of C++ STL is present in the <type_traits> header file. The std::is_trivially_constructible template of C++ STL is used to check whether the given type T is trivially constructible type with the set of arguments or not. It return the boolean value t 2 min read std::is_trivially_constructible in C++ with Examples The std::is_trivially_constructible template of C++ STL is present in the <type_traits> header file. The std::is_trivially_constructible template of C++ STL is used to check whether the given type T is trivially constructible type with the set of arguments or not. It return the boolean value t 2 min read std::is_default_constructible in C++ with Examples The std::is_default_constructible template of C++ STL is present in the <type_traits> header file. The std::is_default_constructible template of C++ STL is used to check whether the T is default constructible or not. A default constructible can be constructed without arguments or initializatio 2 min read std::is_default_constructible in C++ with Examples The std::is_default_constructible template of C++ STL is present in the <type_traits> header file. The std::is_default_constructible template of C++ STL is used to check whether the T is default constructible or not. A default constructible can be constructed without arguments or initializatio 2 min read std::is_trivially_move_constructible in C++ with Examples The std::is_trivially_move_constructible template of C++ STL is present in the <type_traits> header file. The std::is_trivially_move_constructible template of C++ STL is used to check whether the T is trivially move constructibe or not. It return the boolean value true if T is trivially move c 3 min read std::is_trivially_move_constructible in C++ with Examples The std::is_trivially_move_constructible template of C++ STL is present in the <type_traits> header file. The std::is_trivially_move_constructible template of C++ STL is used to check whether the T is trivially move constructibe or not. It return the boolean value true if T is trivially move c 3 min read Like