std::remove_const in C++ with Examples Last Updated : 21 Jun, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The std::remove_const template of C++ STL is present in the <type_traits> header file. The std::remove_const template of C++ STL is used to get the type T without const qualification. It return the boolean value true if T is without const qualified, otherwise return false. Below is the syntax for the same: Header File: #include<type_traits> Template Class: template <class T> struct remove_const; Syntax: std::remove_const<T>::value Parameter: This template std::remove_const accepts a single parameter T(Trait class) to check whether T is without const qualified or not. Return Value: The template std::remove_const returns a boolean value: True: If type T is without const qualified. False: If type T is with const qualified. Below is the program to demonstrate std::remove_const in C++: Program: CPP14 // C++ program to illustrate // std::remove_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 remove_const<int>::type A; typedef remove_const<const int>::type B; typedef remove_const<const int*>::type C; typedef remove_const<int* const>::type D; typedef remove_const<const int&>::type E; cout << std::boolalpha; // Checking const of the above // declared variables cout << "A is without const int? " << is_same<int, A>::value << endl; cout << "B is without const int? " << is_same<int, B>::value << endl; cout << "C is without const int? " << is_same<int, C>::value << endl; cout << "D is without const int? " << is_same<int, D>::value << endl; cout << "E is without const int? " << is_same<const int, E>::value << endl; return 0; } Output: A is without const int? true B is without const int? true C is without const int? false D is without const int? false E is without const int? false Reference: http://www.cplusplus.com/reference/type_traits/remove_const/ Comment More infoAdvertise with us Next Article std::remove_const in C++ with Examples B bansal_rtk_ Follow Improve Article Tags : Misc C++ Programs C++ STL CPP-Functions +1 More Practice Tags : CPPMiscSTL Similar Reads starts_with() and ends_with() in C++20 with Examples In this article, we will be discussing starts_with() and ends_with() with examples in C++20. starts_with() This function efficiently checks if a string begins with the given prefix or not. This function written in both std::basic_string and in std::basic_string_view. Syntax: template <typename P 3 min read How to use const with Pointers in C++? In C++, the const keyword is used as a type qualifier for defining read-only (immutable) objects that cannot be modified anywhere in their lifetime. It can be used in several ways with pointers, each serving a different purpose. In this article, we will learn how to use const qualifier with pointers 3 min read What is const_iterator in C++ STL Containers? In C++ STL, a const_iterator is also an iterator and is used similarly to a regular iterator but its main purpose is to iterate over the elements of the container without actually modifying them in any way. It is similar to passing constant pointers to a function. In this article, we will learn what 2 min read How to Use const_iterator with a Map in C++? In C++, a const_iterator is a type of iterator that points to constant content. This means that using a const_iterator, you can read from but not write to the element it points to. In this article, we will learn how to use a const_iterator with a map in C++ STL. Example: Input: myMap = {{âappleâ, 1} 2 min read How to Traverse a List with const_iterator in C++? In C++, a list is a container used to store data in non-contiguous memory locations. It also provides a constant iterator that provides the constant reference to its elements. In this article, we will discuss how to traverse a list with const_iterator in C++. Example Input: myList = {10,20,30,40,50} 2 min read Like