Boost logo

Boost :

Subject: Re: [boost] [reference_wrapper] Overloading operator() in reference_wrapper
From: Kazutoshi Satoda (k_satoda_at_[hidden])
Date: 2013-05-02 04:07:41


On 2013/05/02 16:08 +0900, Krzysztof Czainski wrote:
> 2013/5/2 Kazutoshi Satoda <k_satoda_at_[hidden]>
>> On 2013/04/09 16:24 +0900, Nathan Crookston wrote:
(snip)
>> > I think it would be valuable to update boost::ref to match the standard
>> > version.
>>
>> Is it OK to require the template argument to be a complete type?
>>
>> The standard version requires complete type for operator() support,
>> which results in sticking on the boost version for some cases.
>>
>> https://groups.google.com/a/isocpp.org/d/msg/std-discussion/_tavlfXkOrc/wIxT3VShJzMJ
(snip)
> Isn't it possible to provide operator() and allow T to be incomplete as
> long as operator() isn't used?

I think it is possible, provided that the proposed update can omit some
parts of the standard version.

The standard version has 4 member typedef which are conditionally
defined: result_type, argument_type, first_argument_type,
second_argument_type. If "to update boost::ref to match the standard
version" includes addition of these members, it requires the argument
type complete to determine the condition to (or not to) define these
typedef. If you decide not to define these typedef based on the
incompleteness, it will likely cause ODR violation.

If these typedef are omitted, the resulting reference_wrapper can't be
used with the standard function adapters etc.
The standard 20.8 [function.objects] p5 says:
> To enable adaptors and other components to manipulate function objects
> that take one or two arguments it is required that the function objects
> correspondingly provide typedefs ...

It sounds hard to accept.

-- 
k_satoda

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