Boost logo

Boost :

Subject: Re: [boost] [Review] Boost.Type Traits Extension ending tomorrow
From: Joachim Faulhaber (afojgo_at_[hidden])
Date: 2011-03-21 07:23:42


2011/3/20 Vicente Botet <vicente.botet_at_[hidden]>:
>
> Joachim Faulhaber wrote:
>
> 2011/3/20 Vicente Botet <vicente.botet_at_[hidden]>:
>>
>> Joachim Faulhaber wrote:
>>
>> 2011/3/19 Frédéric Bron <frederic.bron_at_[hidden]>:
>>> Maybe the set of functions should be something like
>>>
>>> is_callable<plus, LeftOperandType,
> RightOperandType>
>>>
>>> This is interesting,
>>
>> yes, I like it
>>
>>> however it would have to be something like:
>>>
> ::boost::is_callable<::boost::type_traits::operators::plus, LHS,
>> RHS>
>>
>> ideally
>>
>> boost::is_callable<std::plus, Left, Right>
>>
>> but std::op_functors seem to be restricted to singly typed
> functors,
>> which I don't understand,
>>
>>
>> I don't see op_functors in the standard.
>
> What I mean by &quot;op_functors&quot; are function objects that wrap
> operators.
>
> 20.8 Function objects [1]
>
> e.g.
> // 20.8.4, arithmetic operations:
> template <class T> struct plus;
>
>> What do you mean by &quot;restricted to
>> singly typed functors&quot;?
>
> And they are template structs parameterized with a single type T instead
> of e.g.
>
> template <class T, class U=T, class R=T> struct plus;
>
> all three types: Lhs argument type T, rhs argument type U and result type
> R.

Hi Vicente,

there is something nasty about your mail/news reader or the
combination of yours and mine. All the less '<' and greater '>' signs
(and other special characters) are coming in their html encoding
'&gt;' and '&lt;' when they return in your answers. Which is a bit
unpleasant. Either the text is unreadable or I have to substitute all
of them manually.

I use google mail for reading boost list and I have chosen the plain
text option, but maybe everyone is using html-encoding now. The
phenomenon seems to occur only with *your* replies, but I don't know
how others receive the text.

As for function objects

>> 20.8 Function objects [1]
>>
>> e.g.
>> // 20.8.4, arithmetic operations:
>> template <class T> struct plus;

These are part of the old standard as well and their implementation
can be found in header <functional>. They are appearing in the new
standard unaltered, except for an extension for 3 bitwise operations.

// 20.8.7, bitwise operations:
template <class T> struct bit_and;
template <class T> struct bit_or;
template <class T> struct bit_xor;

(that should be renamed to bitwise_xxx IMO in order to be more
consistent with boost::proto naming.)

I see these kinds of functors being used and useful in many contexts
and specifically in boost libraries. Also they seem to be reinvented
from time to time. They should really be available in their more
general form, that is capable of covering all the possible overloads
that are possible for the underlying operators.

e.g.

> template <class T, class U=T, class R=T> struct plus;

but maybe there are specific reasons that forbid such a
generalization. I think there shouldn't be any since the more general
form contains the old specification as a special case.

> Oh, I see.
>
> This extension seems to be not disruptive.
> Maybe someone could make a proposal

What has to be done for that?

Best,
Joachim

-- 
Interval Container Library [Boost.Icl]
http://www.joachim-faulhaber.de

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