[cfe-dev] Template Qualifier Removal Question
Csaba Raduly via cfe-dev
cfe-dev at lists.llvm.org
Mon Aug 13 01:37:09 PDT 2018
Hi Andrew,
On Mon, Aug 13, 2018 at 8:36 AM, Andrew Gozillon via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
> Hi,
>
> I have a question relating to template metafunctions like remove_const that
> split a type from its qualifiers.
>
> I was wondering where in Clang the decision to remove const (or another
> qualifier or pointer) from a type is made when using templates and then
> where it's performed (the new type generated)?
Are you talking about std::remove_const (
https://en.cppreference.com/w/cpp/types/remove_cv ) ?
I have bad news: std::remove_const doesn't remove const from a type.
It merely creates another type.
>From the "Possible implementation" :
template< class T > struct remove_const { typedef T type; };
template< class T > struct remove_const<const T> { typedef T type; };
remove_const<T> creates a new type ( remove_const<T>::type ) which is
exactly the same as T,
except if T is const, remove_const<T>::type isn't.
Csaba
--
You can get very substantial performance improvements
by not doing the right thing. - Scott Meyers, An Effective C++11/14 Sampler
So if you're looking for a completely portable, 100% standards-conformat way
to get the wrong information: this is what you want. - Scott Meyers (C++TDaWYK)
More information about the cfe-dev
mailing list