Why does this C++ template produce an error asking for the missing semicolon? -


i'm typing in code explaining how binders work, "beyond standard library" bjorn karlsson. using visual studio 2010 express, , getting missing semi colon error.

this bit seems fine:

// template simple function object ///////////////////////////////////////////////////////////////////////////// template<typename r, typename t, typename arg>   class simple_bind_t {     typedef r (t::*fn) (arg);  // fn defines type - ptr member fn                                // of object t, returning r, , taking arg      fn _fn;                    // function object owns pointer function.     t  _t;                     // owns object of type t.    public:      simple_bind_t(fn f, const t& t):              _fn(fn), _t(t) {} // instantiate mber variables      r operator()(arg& a)      {        return (_t->_fn)(a);    // invoke member function on t, pass arg.     }    }; 

so bit fine. when go define actual function creates function object, (see code snippet below), little red line underneath r of line r (t::*fn)(arg),. when roll mouse on says - error: expected ';').

template <class r, class t, class arg>     simple_bind_t<r,t,arg> simple_bind (      r (t::*fn)(arg),                           const t& t,      const placeholder&)    { return simple_bind_t<r,t,arg>(fn,t); } // construct object of simple_bind_t<r,t,arg>                                         // pass pointer member function, fn                                         // , object of type t bind to, t 

can spot syntax error is?

you’ve made typo here:

simple_bind_t(fn f, const t& t):          _fn(fn), _t(t) {} // instantiate mber variables // ----------^^ 

fn names type, meant use argument, f. there may other errors since didn’t post complete enough code (for instance, definition of placeholder missing), it’s impossible find them.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -