Automatic type deduction with const_cast is not working
问题 In my work the use of const_cast is under some circumstances unavoidable. Now I have to const_cast some pretty complicated types and actually I don't want to write all this type clutter in the const_cast<Clutter> expressions, especially if Clutter is very long. My first idea was to write const_cast<>(myType) , but my compiler cannot deduce the non-const type of myType . So I thought about helping my compiler and I deviced the following approach, which compiles. #include <stdlib.h> #include