M
Mark P
Just wondering if there's a recommended approach for this:
class Foo
{
stdair< Foo*, Foo* > bar();
std:air< const Foo*, const Foo* > bar() const;
}
The two functions "do" the same thing logically, but for the const
version the return pair comprises pointers to constants. (You can think
of Foo as a linked list node that returns some other nearby nodes.)
Currently I have two essentially identical implementations modulo a few
uses of the keyword const. Is it better to implement the non-const
version in terms of the const version and const_cast the result?
Thanks for your advice,
Mark
class Foo
{
stdair< Foo*, Foo* > bar();
std:air< const Foo*, const Foo* > bar() const;
}
The two functions "do" the same thing logically, but for the const
version the return pair comprises pointers to constants. (You can think
of Foo as a linked list node that returns some other nearby nodes.)
Currently I have two essentially identical implementations modulo a few
uses of the keyword const. Is it better to implement the non-const
version in terms of the const version and const_cast the result?
Thanks for your advice,
Mark