I’m looking to copy an object pointed to by a pointer-to-const (as an argument) within a function to a temporary, stack-allocated copy, which I can manipulate and do various checks on. How do I go about doing this, without cheating by way of const_cast?
bool f(const Foo* foo)
{
(Create a temporary copy of foo)
(Manipulate temporary copy of foo to test validity)
(Output bool)
}
If it is all what your function does, why not just pass by value?