Boost logo

Boost :

Subject: Re: [boost] [property] interest in C# like properties for C++?
From: Olaf van der Spek (olafvdspek_at_[hidden])
Date: 2009-10-24 08:05:18


On Sat, Oct 24, 2009 at 4:11 AM, Bo Persson <bop_at_[hidden]> wrote:
>> Don't you agree that string& name = c.name; name.size() is kinda
>> ugly/unusable compared to just c.name->size() (possible) or
>> c.name.size() (not possible, but ideal)?
>
> I might be stupid here, but can not see any advantage at all for using
> c.name->size() over the traditional c.name().size().

Since references can't be rebound, I'm using a pointer to store the
actual value. So the first syntax doesn't require any modification of
call sites.
The first one looks more natural to me without the ().

> And why is the "ideal" c.cname.size(), should it not be c.name.size
> with size being a property of the string?

Yes, if std::string::size indeed becomes a property. That's unlikely
to happen any time soon though. :(

Olaf


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk