Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 洛基';带可变模板的s函子_C++_Templates_Loki - Fatal编程技术网

C++ 洛基';带可变模板的s函子

C++ 洛基';带可变模板的s函子,c++,templates,loki,C++,Templates,Loki,我有一个关于库Loki的Functor实现的问题。 我正在做一些改变,以使它与可变模板,而不是有一行一行的模板专门化工作。问题是,我试图使用变量模板的typedef,我不理解我的错误,这就是为什么我可以从专家那里得到一些帮助 是头文件 我用一个简单的例子进行了测试: static void foo() { std::cout << "foo !!!" << std::endl; } int main( int argc, const char** argv ) {

我有一个关于库
Loki
Functor
实现的问题。 我正在做一些改变,以使它与可变模板,而不是有一行一行的模板专门化工作。问题是,我试图使用变量模板的typedef,我不理解我的错误,这就是为什么我可以从专家那里得到一些帮助

是头文件

我用一个简单的例子进行了测试:

static void foo()
{
    std::cout << "foo !!!" << std::endl;
}
int
main( int argc, const char** argv )
{
    Functor<void, void> static_func(foo);
    static_func();
}
静态void foo()
{

std::cout any?…我被告知要使用
std::function
,但我更喜欢Loki对
Functor
的实现,因为它也可以使用各种各样的指针作为参数(例如
std::shared\u ptr
)。有没有办法使用
std::function
ResultType操作符()(MyList&&parms)const
如果要将函数(
foo()
在本例中)参数传递给类
Functor
中的
operator()
原型,则该原型是不正确的。
/home/test/src/EntryPoint.cpp:237:17: error: no match for call to ‘(Functor<void, void>) ()’
    In file included from /home/test/src/EntryPoint.cpp:231:0:
    /home/test/include/FunctorTest.h:217:7: note: candidate is:
    /home/test/include/FunctorTest.h:292:16: note: Functor<R, TList>::ResultType Functor<R, TList>::operator()(Functor<R, TList>::MyList&&) const [with R = void; TList = {void}; Functor<R, TList>::ResultType = void; Functor<R, TList>::MyList = variadic_typedef<void>]
    /home/test/include/FunctorTest.h:292:16: note:   candidate expects 1 argument, 0 provided
    /home/test/src/EntryPoint.cpp: At global scope:
    /home/test/src/EntryPoint.cpp:234:1: warning: unused parameter ‘argc’ [-Wunused-parameter]
    /home/test/src/EntryPoint.cpp:234:1: warning: unused parameter ‘argv’ [-Wunused-parameter]
    In file included from /home/test/src/EntryPoint.cpp:231:0:
    /home/test/include/FunctorTest.h: In instantiation of ‘FunctorHandler<ParentFunctor, Fun>::ResultType FunctorHandler<ParentFunctor, Fun>::operator()(FunctorHandler<ParentFunctor, Fun>::MyList&&) [with ParentFunctor = Functor<void, void>; Fun = void (*)(); FunctorHandler<ParentFunctor, Fun>::ResultType = void; FunctorHandler<ParentFunctor, Fun>::MyList = variadic_typedef<void>]’:
    /home/test/src/EntryPoint.cpp:247:1:   required from here
    /home/test/include/FunctorTest.h:159:49: error: no matching function for call to ‘forward(FunctorHandler<Functor<void, void>, void (*)()>::MyList&)’
    /home/test/include/FunctorTest.h:159:49: note: candidates are:
    In file included from /usr/include/c++/4.7/bits/stl_pair.h:61:0,
                     from /usr/include/c++/4.7/utility:72,
                     from /home/jean/Lib/vitals/include/CLPair.h:28,
                     from /home/jean/Lib/vitals/include/CLMap.h:27,
                     from /home/jean/Lib/vitals/include/HTCmdLineParser.h:27,
                     from /home/test/include/EntryPoint.h:23,
                     from /home/test/src/EntryPoint.cpp:22:
    /usr/include/c++/4.7/bits/move.h:77:5: note: template<class _Tp> constexpr _Tp&& std::forward(typename std::remove_reference<_From>::type&)
    /usr/include/c++/4.7/bits/move.h:77:5: note:   template argument deduction/substitution failed:
    In file included from /home/test/src/EntryPoint.cpp:231:0:
    /home/test/include/FunctorTest.h:159:49: note:   cannot convert ‘parms’ (type ‘FunctorHandler<Functor<void, void>, void (*)()>::MyList {aka variadic_typedef<void>}’) to type ‘std::remove_reference<convert_in_tuple<variadic_typedef<void> > >::type& {aka convert_in_tuple<variadic_typedef<void> >&}’