Don't quite get your point. Variable a returns true with is_const before and after the test(a) function is run. That means it stayed const, right?
The compiler was complaining about discarding qualifiers without the const_cast. I wanted to be able to run vect() without changing the constness of &z.
I am trying to integrate code into another program and did not want to mess things up by making unecessary modifications to other parts of the code.
If I understand correctly, this code:
int y = const_cast<myint *>(&z)->vect();
Is just the compiler telling me : "Q. You know z is const right? A. I know, just let me do this once"
I see. I will have to try this. Making vect() a const function would be equivalent to const_cast. In actual project code, vect() returns a pointer to a writeable buffer but the class object it is a member of is const. I will have to check if it will work that way.
The const_cast solution does not seem to have any untoward side effects. It requires less source code modification as well in the project I am working on. I will have to pick that solution unless somebody here thinks I am creating unforeseen problems.