|
Boost : |
Subject: Re: [boost] review request: addition to type_traits library of is_less_comparable<T, U> and others
From: Jeffrey Bosboom (jbosboom_at_[hidden])
Date: 2009-12-09 16:57:53
David Abrahams wrote:
> On Dec 8, 2009, at 7:06 AM, Jeffrey Bosboom wrote:
>
>> David Abrahams wrote:
>>> On Dec 8, 2009, at 6:28 AM, Frédéric Bron wrote:
>>>> 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)?
>> Would this also allow a user to override this behavior when they want to ensure an exact type match?
>
> I suppose so, but seriously, I was not suggesting adding all this complication. I think it should be kept simple and only generalized as far as is proven necessary by real use cases.
I don't have a personal need for this, but I was thinking that it might
be useful in generic code that can use multiple number types. Suppose
you have a some_number class that has a converting constructor from
long. Your generic code might want to ensure that if you add two
some_numbers (a + b) that you get back a some_number, not a long that's
convertible to a some_number.
I'm not sure this is entirely necessary, and there may be other
mechanisms for the user to specify this constraint when it is required.
--Jeffrey Bosboom
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk