Boost logo

Boost :

Subject: Re: [boost] [Review] Boost.Type Traits Extension by Frederic Bron
From: Jeffrey Lee Hellrung, Jr. (jhellrung_at_[hidden])
Date: 2011-03-17 18:42:09


On 3/17/2011 3:19 PM, Joachim Faulhaber wrote:
> 2011/3/17 Jeffrey Lee Hellrung, Jr.<jhellrung_at_[hidden]>:
[...]
>> Here is my understanding of what *should* be happening, although I'd have to
>> take a closer look at the implementation and/or wait for Frederic to
>> verify/refute this assertion.
>>
>> You do want to use type qualifiers in the arguments if you care about
>> constness or copy constructibility. E.g., has_operator_xxx< some_type& >
>> might be true while has_operator_xxx< some_type> and/or has_operator_xxx<
>> some_type const& > could be false, depending on the signature of
>> operator_xxx. E.g., std::map<...>::operator[].
>>
>> Basically, you should invoke the has_operator_xxx metafunctions with
>> argument types (including const and reference qualifiers) that match how you
>> actually invoke the operator. Same deal as with boost::result_of.
>
> It seems like these rules should be put down in the documentation
> along with some good illustrating examples.

Actually, I'm wrong, at least regarding the current implementation.

It looks like a reference qualifier is assumed for the argument types,
so only const (and volatile) qualifiers matter (indeed, the current
implementation probably won't compile on C++03, due to "reference of
reference errors"). And indeed, implicit in the documentation, all
operator traits assume the arguments are lvalues.

Is this the desired behavior? I guess I've been influenced by

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf

in 3.4 "Function return types" [tr.func.ret], page 23, regarding result_of:

"Given an rvalue f of type F and values t1, t2, ..., tN of types T1, T2,
..., TN, respectively, the type member is the result type of the
expression f(t1, t2, ...,tN). The values ti are lvalues when the
corresponding type Ti is a reference type, and rvalues otherwise."

The Boost.ResultOf documentation references this document, but at the
same time there is no explicit distinction between lvalues and rvalues.

- Jeff


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