std::add_volatile in C++ with Examples Last Updated : 12 Jun, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report 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<type_traits> Template Class: template < class T > struct add_volatile; Syntax: std::add_volatile<T>::value Parameter: The template std::add_volatile accepts a single parameter T(Trait class) which is used to get the type T with volatile qualification. Below is the program to demonstrate std::add_volatile: in C++: Program: CPP // C++ program to illustrate // std::add_volatile #include <bits/stdc++.h> #include <type_traits> using namespace std; // Driver Code int main() { // Declare variable of type // volatile (int, const int, const int*, // int * const and const int&) typedef add_volatile<int>::type A; typedef add_volatile<volatile int>::type B; typedef add_volatile<int* volatile>::type C; typedef add_volatile<volatile int*>::type D; typedef add_volatile<volatile int&>::type E; cout << boolalpha; // Checking the volatileness of // the above declared variable cout << "checking volatileness:" << endl; cout << "A: " << is_volatile<A>::value << endl; cout << "B: " << is_volatile<B>::value << endl; cout << "C: " << is_volatile<C>::value << endl; cout << "D: " << is_volatile<D>::value << endl; cout << "E: " << is_volatile<E>::value << endl; return 0; } Output: checking volatileness: A: true B: true C: true D: true E: false Reference: http://www.cplusplus.com/reference/type_traits/add_volatile/ Comment More infoAdvertise with us Next Article std::add_volatile in C++ with Examples B bansal_rtk_ Follow Improve Article Tags : Misc C++ CPP-Functions Practice Tags : CPPMisc Similar Reads std::remove_volatile in C++ with Examples The std::remove_volatile template of C++ STL is present in the <type_traits> header file. The std::remove_volatile template of C++ STL is used to get the T without volatile qualification. It return the boolean value true if T is without volatile qualified, otherwise return false. Below is the 2 min read std::to_address in C++ with Examples The std::to_address, introduced in C++20, is used to obtain the address represented by the specified pointer without forming a reference to the pointee. The existing std::addressof cannot do std::addressof(*ptr) because *ptr isnât always an object. The std::to_address solves these issues for us. Syn 2 min read 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_const in C++ with Examples 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> Tem 2 min read Storage Classes in C++ with Examples C++ Storage Classes are used to describe the characteristics of a variable/function. It determines the lifetime, visibility, default value, and storage location which helps us to trace the existence of a particular variable during the runtime of a program. Storage class specifiers are used to specif 6 min read Like