Title
Ambiguous move overloads in function
Status
c++11
Section
[func.wrap.func]
Submitter
Howard Hinnant

Created on 2009-03-19.00:00:00 last changed 161 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

Change the synopsis of [func.wrap.func], and remove the associated definitions in [func.wrap.func.con]:

template<Returnable R, CopyConstructible... ArgTypes> 
class function<R(ArgTypes...)>
{
    ...
    template<class F> 
      requires CopyConstructible<F> && Callable<F, ArgTypes...> 
            && Convertible<Callable<F, ArgTypes...>::result_type, R> 
      function(F); 
    template<class F> 
      requires CopyConstructible<F> && Callable<F, ArgTypes...> 
            && Convertible<Callable<F, ArgTypes...>::result_type, R> 
      function(F&&);
    ...
    template<class F, Allocator Alloc> function(allocator_arg_t, const Alloc&, F); 
    template<class F, Allocator Alloc> function(allocator_arg_t, const Alloc&, F&&);
    ...
    template<class F> 
      requires CopyConstructible<F> && Callable<F, ArgTypes..> 
            && Convertible<Callable<F, ArgTypes...>::result_type 
      function& operator=(F); 
    template<class F> 
      requires CopyConstructible<F> && Callable<F, ArgTypes...> 
            && Convertible<Callable<F, ArgTypes...>::result_type, R> 
      function& operator=(F&&);
    ...
};
Date: 2010-10-21.18:28:33

[ Batavia (2009-05): ]

We briefly discussed whether we ought support moveable function objects, but decided that should be a separate issue if someone cares to propose it.

Move to Tentatively Ready.

Date: 2009-05-01.00:00:00

[ 2009-05-01 Daniel adds: ]

1024 modifies the second removed constructor.

Date: 2009-03-19.00:00:00

The synopsis in [func.wrap.func] says:

template<Returnable R, CopyConstructible... ArgTypes> 
class function<R(ArgTypes...)>
{
    ...
    template<class F> 
      requires CopyConstructible<F> && Callable<F, ArgTypes...> 
            && Convertible<Callable<F, ArgTypes...>::result_type, R> 
      function(F); 
    template<class F> 
      requires CopyConstructible<F> && Callable<F, ArgTypes...> 
            && Convertible<Callable<F, ArgTypes...>::result_type, R> 
      function(F&&);
    ...
    template<class F, Allocator Alloc> function(allocator_arg_t, const Alloc&, F); 
    template<class F, Allocator Alloc> function(allocator_arg_t, const Alloc&, F&&);
    ...
    template<class F> 
      requires CopyConstructible<F> && Callable<F, ArgTypes..> 
            && Convertible<Callable<F, ArgTypes...>::result_type 
      function& operator=(F); 
    template<class F> 
      requires CopyConstructible<F> && Callable<F, ArgTypes...> 
            && Convertible<Callable<F, ArgTypes...>::result_type, R> 
      function& operator=(F&&);
    ...
};

Each of the 3 pairs above are ambiguous. We need only one of each pair, and we could do it with either one. If we choose the F&& version we need to bring decay into the definition to get the pass-by-value behavior. In the proposed wording I've gotten lazy and just used the pass-by-value signature.

History
Date User Action Args
2011-08-23 20:07:26adminsetstatus: wp -> c++11
2010-10-21 18:28:33adminsetmessages: + msg580
2010-10-21 18:28:33adminsetmessages: + msg579
2010-10-21 18:28:33adminsetmessages: + msg578
2009-03-19 00:00:00admincreate