Boost logo

Boost :

Subject: Re: [boost] [property] interest in C# like properties for C++?
From: Stefan Strasser (strasser_at_[hidden])
Date: 2009-10-22 23:35:39

Am Friday 23 October 2009 01:41:57 schrieb Sid Sacek:
> >> [ Edward Diener wrote: ]
> >> Manipulating a reference property would be done purely through
> >> accessing the property. Accessing a reference property returns a T & or
> >> a T const & depending on whether the property is const or not. In the
> >> case where a T & is returned the reference property is read/write if T
> >> itself is not const, since you can manipulate T through the reference,
> >> whereas in the case where T const & is returned ( or where T & is
> >> returns but T is itself const), the reference property is read only.
> Who says that's how properties work? That just happens to be your version
> of the implementation details.

I don't understand what a "reference property" is supposed to be. a property
getter can return a reference (if it chooses to do so, not in general, since
there may not be an underlying data member), but what is a reference

whether the value obtained through the getter is stored inside the object
itself or only referenced by the object doesn't matter to the interface.

the example given for a "reference property":
struct D{
  C& c;

is equivalent to

struct D{
  C c;

from the perspective of the user of the class interface.
so why would there be a difference when the same thing is implemented as
a "property"? and what is the difference?

to the general discussion, I think there needs to be an agreed upon definition
of a property first, before talking about library implementations.

I defined a property to be "a property of an object" in general, e.g. the
width of a rectangle, with the syntax to obtain that property from the object
as an irrelevant detail, as long as it's standardized.
that's why I came to the conclusion that c++ already has a syntax for

others seem to have the goal to emulate a C# language construct
called "property" in C++.

a third concern was a simpler definition of default/trivial properties, with
whatever syntax to access them.

Boost list run by bdawes at, gregod at, cpdaniel at, john at