Loki's Functor with variadic templates

穿精又带淫゛_ 提交于 2019-12-11 03:20:21

问题


I have a question about the Functor implementation of the library Loki. I am doing some changes in order to make it work with variadic templates instead of having lines and lines of template specialization. The problem is that I am trying to use typedef for variadic template and I do not understand my error, that is why I could use some help from experts...

Here is the header file.

I tested it with a simple example:

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

Which gives me this error

/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> >&}’

来源:https://stackoverflow.com/questions/20599849/lokis-functor-with-variadic-templates

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!