"Garth N. Wells" <[email protected]> writes:

> The question is applicable to cases in which we presently have:
>
>     const Foo& foo() const { return _foo; }
>     Foo& foo() { return _foo; }
>
> This does not hide data.

That depends on the context.  Suppose another field is added that must
be kept compatible with _foo.  The interface above lets you maintain
consistency, but a public data member does not.  Similarly, if _foo must
be positive or something, if you decide to use a different basis for
(_foo and other stuff), or if you convert the class to delegator/PIMPL
to get ABI stability and speed up compiles.

Sometimes the semantic of the field implies that none of this is
possible, in which case a public member is more honest.
_______________________________________________
fenics mailing list
[email protected]
http://fenicsproject.org/mailman/listinfo/fenics

Reply via email to