I have a problem with duplication of identical code for const
and non-const
versions. I can illustrate the problem with some code. Here are two s
Normally with this type of thing, it's possibly better to use methods that make sense. For example, load()
and save()
. They say something specific about the operation that is to be carried out via the visitor. Typically both a const and non-const version is provided (for things like accessors anyway), so it only appears to be duplication, but could save you some headache debugging later down the line. If you really wanted a workaround (which I wouldn't advice), is to declare the method const
, and all the members mutable
.