|
Boost : |
Subject: Re: [boost] Concept Traits Library
From: Jeffrey Lee Hellrung, Jr. (jhellrung_at_[hidden])
Date: 2010-07-10 18:31:41
On 7/10/2010 12:49 PM, Frédéric Bron wrote:
[...]
> What I can say is that there is some differences between the traits I
> proposed and the one of the CTL: in CTL, there is no check of return
> type. We had quite a long dicussion about this and ended to a nice
> solution which is to check or not (optional) for the return type to be
> convertible to a given type.
I've found all 3 of the following options to be useful in my own (C++03)
implementation of operator traits:
(i) ignore the return type of the operator entirely
(ii) check that the return type of the operator is convertible to a
given type
(iii) check that the return type of the operator satisfies a given MPL
metafunction class or MPL lambda expression
As a result, the trait's signature looks something like
template<
class T,
class Result = void,
class ResultCond = mpl::always< true_type >
>
struct my_trait;
The trait evaluates to true if the result type of the operator
- is convertible to Result or Result is void; and
- satisfies ResultCond.
Of course, option (iii) is a generalization of (ii), but (ii) (along
with (i)) would be the common case (and hence providing an interface
specifically for (ii) would be more client-friendly). A use case for
(iii) might be to check that the return type is *precisely* the given
type, or if the return type is one of many
compatible-but-not-necessarily-interconvertible types.
> If we agree to add only the operator traits to the type_traits library
> separatly from the CTL, I think that my proposal is nearly ready and I
> can do the extra work. If we want to add the CTL, it is better if
> someone else does it as it would be too much work for me.
Is your proposal available for inspection at the moment? I don't recall
recently running across a link that you've provided. Sorry if I missed
it :/
- Jeff
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk