继承自std :: function,语法和用法?

LPr*_*Prc 3 c++ inheritance class functor c++11

当函子从std :: function继承时,我不理解语法:

class do_sth : public function< any_type (another_type) >
{
    bool operator() (string s) {...}
};
Run Code Online (Sandbox Code Playgroud)

我应该作为any_type和another_type使用什么?而且您能给我一个例子的例子,因为我还不了解它,它从std :: function继承的好处?

Seb*_*edl 6

您应该使用operator ()for 的返回类型any_type和的参数类型another_type。然后至少适合。

但是,实际上,std::function这并不意味着要继承它,这样做可能是个坏主意。