Boost logo

Boost :

Subject: Re: [boost] [Review] Boost.Type Traits Extension by Frederic Bron
From: Frédéric Bron (frederic.bron_at_[hidden])
Date: 2011-03-19 02:48:18


> The only suggestion I would like to make regarding the design is in the
> default argument for the return value, which tells the implementation not to
> check for the return value. While it is wildly improbable that any user of
> the operator traits would actually want to have a trait whose return is
> actually 'void', it is still theoretically possible. Therefore I think that
> the default for the return value, which means to not check for the return
> value, should be an unspecified marker type in the type_traits::detail
> namespace. It is a convention of all Boost libraries that any library's
> detail namespace is to be used only by the implementation of that library
> and not by a user of that library. So using an unspecified marker type in
> the type traits detail namespace should be fine.

Good news for the return type of operators: I have been able to check
for exact void return and have default "dont_care":

template< class LHS, class RHS=LHS, class RET=dont_care >
has_operator_plus;

1. operator+(A, A) exists and returns void

has_operator_plus<A, A>::value -> true (dont check return type)
has_operator_plus<A, A, void>::value -> true (check for exact void return type)
has_operator_plus<A, A, R>::value -> false (void!=R)

2. operator+(A, A) exists and returns R!=void

has_operator_plus<A, A>::value -> true (dont check return type)
has_operator_plus<A, A, void>::value -> false (void!=R)
has_operator_plus<A, A, R>::value -> true (void!=R)

3. operaot+(A, A) does not exist

has_operator_plus<A, A>::value -> false
has_operator_plus<A, A, void>::value -> false
has_operator_plus<A, A, R>::value -> false

I think this is now much better.

Frédéric


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk