Topic: Why std::function have not provided methods to assign from the
Author: jinhao <cnjinhao@hotmail.com>
Date: Fri, 9 Dec 2011 23:54:36 -0800 (PST)
Raw View
Refer to the definition of std::function.
template<class R, class... ArgTypes>
class function<R(ArgTypes...)> {
public:
//...
function& operator=(const function&);
function& operator=(function&&);
function& operator=(nullptr_t);
template<class F> function& operator=(F&&);
template<class F> function& operator=(reference_wrapper<F>) noexcept;
template<class F, class A> void assign(F&&, const A&);
//...
};
There is a problem.
void foo();
void foo(int);
std::function<void()> fn;
fn = foo; //Error! 'void foo()'? or 'void foo(int)'?
Why not provide a method for std::function to fix the problem? like this.
function& operator=(R(ArgTypes...));
Thanks.
Jinhao
--
[ comp.std.c++ is moderated. To submit articles, try posting with your ]
[ newsreader. If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]