I have a template class similar to this:
template<T>
class MyClass
{
T* data;
}
Sometimes I want to use a class with a constant type T as follows:
MyClass<const MyObject> mci;
but I want to change the data with const_cast<MyObject*>data(this is not important why, but the MyClassclass of smart link pointers that stores the link counter in the data itself. MyObjectcomes from some type that contains the counter. Data should not be changed, but the account should be changed smart pointer.).
Is there a way to remove a constant from T? Fictional code:
const_cast<unconst T>(data)
?
source
share