Movatterモバイル変換


[0]ホーム

URL:



This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++11 status.

987.reference_wrapper and function types

Section: 22.10.6[refwrap]Status:C++11Submitter: Howard HinnantOpened: 2009-02-18Last modified: 2016-01-28

Priority:Not Prioritized

View all otherissues in [refwrap].

View all issues withC++11 status.

Discussion:

The synopsis in 22.10.6[refwrap] says:

template <ObjectType T> class reference_wrapper...

And then paragraph 3 says:

The template instantiationreference_wrapper<T> shall bederived fromstd::unary_function<T1, R> only if the typeT is any of the following:

But function types are notObjectTypes.

Paragraph 4 contains the same contradiction.

[Post Summit:]

Jens: restricted reference to ObjectType

Recommend Review.

[Post Summit, Peter adds:]

Inhttps://svn.boost.org/trac/boost/ticket/1846however Eric Niebler makes the very reasonable point thatreference_wrapper<F>,whereF is a function type, represents a reference to a function,a legitimate entity. Soboost::ref was changed to allow it.

http://svn.boost.org/svn/boost/trunk/libs/bind/test/ref_fn_test.cpp

Therefore, I believe an alternative proposed resolution for issue 987 could simplyallowreference_wrapper to be used with function types.

[Post Summit, Howard adds:]

I agree with Peter (and Eric). I got this one wrong on my first try. Hereis code that demonstrates how easy (and useful) it is to instantiatereference_wrapper with a function type:

#include <functional>template <class F>void test(F f);void f() {}int main(){    test(std::ref(f));}

Output (link time error shows type ofreference_wrapper instantiatedwith function type):

Undefined symbols:  "void test<std::reference_wrapper<void ()()> >(std::reference_wrapper<void ()()>)",...

I've taken the liberty of changing the proposed wording to allow function typesand set to Open. I'll also freely admit that I'm not positiveReferentTypeis the correct concept.

[Batavia (2009-05):]

Howard observed thatFunctionType,a concept not (yet?) in the Working Paper,is likely the correct constraint to be applied.However, the proposed resolution provides an adequate approximation.

Move to Review.

[2009-05-23 Alisdair adds:]

By constraining toPointeeType we rule out the ability forT to be areference, and call in reference-collapsing. I'm not sure if this iscorrect and intended, but would like to be sure the case was considered.

Is dis-allowing reference types and theimplied reference collapsing the intended result?

[2009-07 Frankfurt]

Moved from Review to Open only because the wording needs to betweaked for concepts removal.

[2009-10-14 Daniel provided de-conceptified wording.]

[2009-10 post-Santa Cruz:]

Move to Tentatively Ready.

Proposed resolution:

Change 22.10.6[refwrap]/1 as indicated:

reference_wrapper<T> is aCopyConstructible andCopyAssignable wrapper around areference to an objector function of typeT.


[8]ページ先頭

©2009-2026 Movatter.jp