Subject: Re: [boost] review request: addition to type_traits library of is_less_comparable<T, U> and others
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2009-12-08 09:12:54
David Abrahams wrote:
> On Dec 8, 2009, at 6:28 AM, Frédéric Bron wrote:
> > John Maddock wrote:
> >> Rob Stewart wrote:
> >>> Frédéric Bron wrote:
> >>>>> If you really want to support the "don't care"
> >>>>> case for a return type, use has_operator_less<T,
> >>>>> dont_care> where
> >>>>> "dont_care" is a special placeholder type that you define
> >>>>> (could use a better name though?).
> >>> I like the idea and the name, though perhaps "any" would
> >>> work, too.
> >> Doesn't that potentially get confused with boost::any ?
Eh, maybe, but I don't think so. The idea is similar -- any type -- and the documentation will clearly indicate what "any" means in this case. As Frédéric wrote, the test is always for is_convertible_to, not an exact match, so I think the name fits well.
> > It would be has_operator<T, U, boost::type_traits::any>
> > Then boost::type_traits::any_return would be more appropriate.
That is clear, doesn't conflict with boost::any, but also seems overly long. How about "whatever!" :0) Seriously, "anything" might be a good compromise.
> > I prefer void because it is shorter but this could make people think
> > it will check for operator return void... which is not the case; so
> > maybe the long version boost::type_traits::any_return is better.
> By that rationale shouldn't we also require the 3rd parameter
> to be wrapped in is_convertible_to<...> so people don't think
> it's requiring a return type of exactly R (e.g. bool)?
Since is_convertible_to is always implied, and any type can be converted -- using the term loosely -- to no type, "void" might not be confusing. The name used in this context could be left to reviewers to choose.
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