Subject: Re: [boost] [conversion] How to repere assignement to a variable? (was [property] interest in C# like properties for C++?)
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2009-10-22 10:58:31
> in the thread about C# like properties we were talking about
> the advantage to be able to repere assignation to properties.
I assume by "repere assignation" you mean, in English, "represent assignment." ("Assignation" is not used, normally, as a synonym for "assignment.")
> I said that, another way to repare the assignments is to use
> a free function assign_to, like we use the free function
> swap, or the cast family functions.
> assign_to(a.p_X, 1);
> assign_to call by default the assignment operator.
That's a reasonable default while permitting customization. The idea is reasonable, because it can be customized to recognize properties, however implemented, as well as normal data types, to provide a common "assignment syntax" that adapts to the types used.
However, operator = can be likewise customized and is idiomatic for assignment. Why create a new name?
> If we want transitive assignation
> a = b = c;
> we could do
> assign_to(a, assign_to(b, c));
> and if we find this not really readable we can try with
> tie(a) = tie(b) = c;
Neither is good, but transitive assignment can be ignored; it is hardly a critical feature. (I rarely use it.)
Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP http://www.sig.com
IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk