Tech Off Post

Single Post Permalink

View Thread: C++0x (vs2010) question, please tell me what i'm doing wrong
  • User profile image

    Why do i have to type "test_c<int, void(int)>" instead of just "test_c<int>"


    It works for test_f due to "template argument deduction". This applies only to template functions, not to template classes.


    How to make this compile. What am i missing / doing wrong.


    Don't use void(int). That simply means a function that takes an int and returns nothing. normal_struct_func is not a function, it's an object that has a () operator aka function object, functor etc. You could use std::function (make sure you include <functional>):


    test_c<int, std::function<void(int)>> tc3(33, normal_struct_func());