I have a question about the implementation of the Loki Functor library. I am making some changes to make it work with variable templates, and not with lines and lines of template specialization. The problem is that I am trying to use typedef for a variational pattern, and I do not understand my mistake, so I could use some expert help ...
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(); }
What 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> >&}'
c ++ templates loki
Athanase
source share