Hello!
Suppose I'm using an external API, and in that API, they define:
const Bar& Foo() const;
So this function returns a Bar by reference.
Now, I have a function
void f()
{
Bar P = Foo();
}
Is it safe to const_cast whatever is returned by Foo? I want to change the object Foo returns, but it returns a const Bar, so the compiler gives me an error. I know I can const_cast, and then everything works (I've tried it), but is it safe? Or should I do something else?
Thanks!