std::add_const in C++ with Examples Last Updated : 12 Jun, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The std::add_const template of C++ STL is present in the <type_traits> header file. The std::add_const template of C++ STL is used to get the type T with const qualification. The std::is_volatile is used to check if type T is const qualified or not. Header File: #include<type_traits> Template Class: template < class T > struct add_const; Syntax: std::add_const<T>::value Parameter: The template std::add_const accepts a single parameter T(Trait class) which is used to declare the type T as a const qualified. Below is the program to demonstrate std::add_const: in C++: Program: CPP // C++ program to illustrate // std::add_const #include <bits/stdc++.h> #include <type_traits> using namespace std; // Driver Code int main() { // Declare variable of type // int, const int, const int*, // int * const and const int& typedef add_const<int>::type A; typedef add_const<const int>::type B; typedef add_const<const int*>::type C; typedef add_const<int* const>::type D; typedef add_const<const int&>::type E; cout << std::boolalpha; // Checking const of the above // declared variables cout << "A is const int? " << is_same<const int, A>::value << endl; cout << "B is const int? " << is_same<const int, B>::value << endl; cout << "C is const int? " << is_same<const int, C>::value << endl; cout << "D is const int? " << is_same<const int, D>::value << endl; std::cout << "E is const int? " << is_same<const int, E>::value << endl; return 0; } Output: A is const int? true B is const int? true C is const int? false D is const int? false E is const int? false Reference: http://www.cplusplus.com/reference/type_traits/add_const/ Comment More infoAdvertise with us Next Article std::add_const in C++ with Examples B bansal_rtk_ Follow Improve Article Tags : Misc C++ CPP-Functions Practice Tags : CPPMisc Similar Reads std::add_cv in C++ with Examples The std::add_cv template of C++ STL is present in the <type_traits> header file. The std::add_cv template of C++ STL is used to get the type T with const and volatile qualification. The function std::is_same::value is used to check whether T is a const and volatile qualification or not. Header 2 min read std::add_volatile in C++ with Examples The std::add_volatile template of C++ STL is present in the <type_traits> header file. The std::add_volatile template of C++ STL is used to get the type T with volatile qualification. The function std::is_volatile is used to check if type T is volatile qualified or not. Header File: #include 2 min read std::add_lvalue_reference in C++ with Examples The std::add_lvalue_reference template of C++ STL is present in the <type_traits> header file. The std::add_lvalue_reference template of C++ STL is used to get lvalue reference type that refers to T type. An lvalue reference is formed by placing an '&' after some type. An rvalue reference 2 min read std::extent() template in C++ with Examples The std::is_const template of C++ STL is present in the <type_traits> header file. If A is an array that has a rank greater than B, the extent is the bound of the Ath dimension and if B is zero and A is the array of unknown bound, than the extent value is zero. Header File: #include<type_tr 2 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