Title
Unclear inheritance relation for std::function
Status
nad editorial
Section
[func.wrap.func]
Submitter
Alisdair Meredith

Created on 2009-03-11.00:00:00 last changed 164 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

(no changes to <functional> synopsis required)

Change synopsis in Class template function [func.wrap.func]:

template<Returnable R, CopyConstructible... ArgTypes> 
class function<R(ArgTypes...)> 
  : public unary_function<T1, R>      // iff sizeof...(ArgTypes) == 1 and see below
                                      // ArgTypes contains T1
  : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and see below
                                      // ArgTypes contains T1 and T2
{
   ...

Add new p1/p2 before [func.wrap.func.con]:

The template instantiation function<R(T1)> shall be publicly and unambiguously derived from std::unary_function<T1,R> if and only if the template type parameter is a function type taking one argument of type T1 and returning R.

The template instantiation function<R(T1,T2)> shall be publicly and unambiguously derived from std::binary_function<T1,T2,R> if and only if the template type parameter is a function type taking two arguments of type T1 and T2 and returning R.

explicit function();
Date: 2010-10-21.18:28:33

[ Batavia (2009-05): ]

We agree with the proposed wording. Move to NAD Editorial.

Date: 2009-05-09.00:00:00

[ 2009-05-09 Alisdair adds: ]

Phrasing should be "publicly and unambiguously derived from" and probably back in reference_wrapper too. Updated wording supplied.

Date: 2010-10-21.18:28:33

[ Summit: ]

Agree. std::reference_wrapper has the same structure, and we suggest that std::function be presented in the same way as std::reference_wrapper.

Date: 2012-10-21.13:19:07

Addresses DE 22 [CD1]

Related to issue 1114.

The conditions for deriving from std::unary_function and std::binary_function are unclear: The condition would also be satisfied if ArgTypes were std::vector<T1>, because it (arguably) "contains" T1.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg362
2010-10-21 18:28:33adminsetmessages: + msg361
2010-10-21 18:28:33adminsetmessages: + msg360
2010-10-21 18:28:33adminsetmessages: + msg359
2009-03-11 00:00:00admincreate