Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Semantics of std::function's constructors

96 views
Skip to first unread message

Roman Perepelitsa

unread,
Mar 20, 2014, 2:13:09 AM3/20/14
to
Both C++11 and the C++14 draft seem to be missing semantics
of several std::function's constructors.

[func.wrap.func]:

// 20.9.11.2.1, construct/copy/destroy:
function() noexcept;
function(nullptr_t) noexcept;
function(const function&);
function(function&&);
template<class F> function(F);
template<class A> function(allocator_arg_t, const A&) noexcept;
...

20.9.11.2.1 function construct/copy/destroy [func.wrap.func.con]
defines semantics for the constructors with allocator_arg_t as
the first parameter but not, for example, template<class F> function(F).

Is that an oversight or am I missing something?

I'm trying to understand whether template<class F> function(F) is
required to participate in overload resolution if and only if F is
Callable for argument types ArgTypes and return type R.

Roman Perepelitsa.


--
[ comp.std.c++ is moderated. To submit articles, try posting with your ]
[ newsreader. If that fails, use mailto:std-cpp...@vandevoorde.com ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]

Daniel Krügler

unread,
Mar 21, 2014, 4:11:45 PM3/21/14
to
Am 20.03.2014 07:13, schrieb Roman Perepelitsa:
>
> Both C++11 and the C++14 draft seem to be missing semantics
> of several std::function's constructors.
>
> [func.wrap.func]:
>
> // 20.9.11.2.1, construct/copy/destroy:
> function() noexcept;
> function(nullptr_t) noexcept;
> function(const function&);
> function(function&&);
> template<class F> function(F);
> template<class A> function(allocator_arg_t, const A&) noexcept;
> ...
>
> 20.9.11.2.1 function construct/copy/destroy [func.wrap.func.con]
> defines semantics for the constructors with allocator_arg_t as
> the first parameter but not, for example, template<class F> function(F).
>
> Is that an oversight or am I missing something?


As of acceptance of LWG 2132

http://cplusplus.github.io/LWG/lwg-defects.html#2132

this has been clarified. We have now for

template<class F> function(F f);
template <class F, class A> function(allocator_arg_t, const A& a, F f);

the following normative wording in [func.wrap.func.con] p8:

Remarks: These constructors shall not participate in overload
resolution unless f is Callable (20.9.11.2) for argument types
ArgTypes... and return type R.

> I'm trying to understand whether template<class F> function(F) is
> required to participate in overload resolution if and only if F is
> Callable for argument types ArgTypes and return type R.


It is now, but wasn't before.

HTH & Greetings from Bremen,

Daniel Krügler
0 new messages