|
Boost : |
Subject: Re: [boost] markable -- informal review request
From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2016-09-20 19:32:33
On 20 Sep 2016 12:04 pm, "Andrzej Krzemienski" <akrzemi1_at_[hidden]> wrote:
>
[...].
>
> One could consider other alternatives like "magic_val", but they are not
> much better, and do not transform into adjectives and verbs that easily
> ("magic_valued"?).
>
> Does that sound convincing?
>
Maybe.
More seriously, yes please submit it to boost, I have seen reinvented (a
few by myself) this too many times. A few comments:
* Consider, maybe, a different name (OK, OK I'll stop).
* The first template parameter should be the stored T itself, pass the
policy as a separate optional parameter.
* Pick a sensible default policy. I like nan for floats, otherwise value
initialisation is a good default. For integers is easy to have a policy
specifying the value inline.
* to avoid the bag of functions issue with policies, consider using ADL for
customisation and use the stateless policy just to drive the lookup.
* The policy itself can be used for tagging, no need for an extra parameter.
* Markable should be trivially copyable, assignable and destructible when
the underlying T is, at least when not using the pod storage policy. This
might be already the case.
* Add flatMap?
That's all for now,
-- gpd
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk