Created on 2009-02-18.00:00:00 last changed 161 months ago
Proposed resolution:
Change [refwrap]/1 as indicated:
reference_wrapper<T> is a CopyConstructible and CopyAssignable wrapper around a reference to an object or function of type T.
[ 2009-10 post-Santa Cruz: ]
Move to Tentatively Ready.
[ 2009-10-14 Daniel provided de-conceptified wording. ]
[ 2009-07 Frankfurt ]
Moved from Review to Open only because the wording needs to be tweaked for concepts removal.
[ 2009-05-23 Alisdair adds: ]
By constraining to PointeeType we rule out the ability for T to be a reference, and call in reference-collapsing. I'm not sure if this is correct and intended, but would like to be sure the case was considered.
Is dis-allowing reference types and the implied reference collapsing the intended result?
[ Batavia (2009-05): ]
Howard observed that FunctionType, 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.
[ Post Summit, Howard adds: ]
I agree with Peter (and Eric). I got this one wrong on my first try. Here is code that demonstrates how easy (and useful) it is to instantiate reference_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 of reference_wrapper instantiated with 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 types and set to Open. I'll also freely admit that I'm not positive ReferentType is the correct concept.
[ Post Summit, Peter adds: ]
In https://svn.boost.org/trac/boost/ticket/1846 however Eric Niebler makes the very reasonable point that reference_wrapper<F>, where F is a function type, represents a reference to a function, a legitimate entity. So boost::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 simply allow reference_wrapper to be used with function types.
[ Post Summit: ]
Jens: restricted reference to ObjectType
Recommend Review.
The synopsis in [refwrap] says:
template <ObjectType T> class reference_wrapper ...
And then paragraph 3 says:
The template instantiation reference_wrapper<T> shall be derived from std::unary_function<T1, R> only if the type T is any of the following:
- a function type or a pointer to function type taking one argument of type T1 and returning R
But function types are not ObjectTypes.
Paragraph 4 contains the same contradiction.
History | |||
---|---|---|---|
Date | User | Action | Args |
2011-08-23 20:07:26 | admin | set | status: wp -> c++11 |
2010-10-21 18:28:33 | admin | set | messages: + msg4698 |
2010-10-21 18:28:33 | admin | set | messages: + msg4697 |
2010-10-21 18:28:33 | admin | set | messages: + msg4696 |
2010-10-21 18:28:33 | admin | set | messages: + msg4695 |
2010-10-21 18:28:33 | admin | set | messages: + msg4694 |
2010-10-21 18:28:33 | admin | set | messages: + msg4693 |
2010-10-21 18:28:33 | admin | set | messages: + msg4692 |
2010-10-21 18:28:33 | admin | set | messages: + msg4691 |
2010-10-21 18:28:33 | admin | set | messages: + msg4690 |
2009-02-18 00:00:00 | admin | create |