Problem with templatized overloaded operator ()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • StephQ

    #1

    Problem with templatized overloaded operator ()

    I can't get this code working:

    class Scheme_euler
    {
    private:
    ....

    public:
    ....

    template<class D, double (D::*drift)(dou ble) const, double
    (D::*diffu)(dou ble) const>
    void operator ()(Path& thePath, const D& theD) const;
    };

    Scheme_euler theEu(0, 1, 100); //constructor
    theEu<Diff_sine , &Diff_sine:: mu, &Diff_sine::sig ma>
    (thePath, theDiff_sine);

    However if I don't overload the operator () but just consider a member
    solve function, then using:
    theEu.solve<Dif f_sine, &Diff_sine:: mu, &Diff_sine::sig ma>
    (thePath, theDiff_sine);
    woks fine.

    So the problem is in overloading the operator, but I can't understand
    where I'm wrong.

    Thank you in advance for your help!
    StephQ

  • amparikh@gmail.com

    #2
    Re: Problem with templatized overloaded operator ()

    On Mar 11, 12:43 pm, "StephQ" <askmeo...@mail inator.comwrote :
    I can't get this code working:
    >
    class Scheme_euler
    {
    private:
    ....
    >
    public:
    ....
    >
    template<class D, double (D::*drift)(dou ble) const, double
    (D::*diffu)(dou ble) const>
    void operator ()(Path& thePath, const D& theD) const;
    >
    };
    >
    Scheme_euler theEu(0, 1, 100); //constructor
    theEu<Diff_sine , &Diff_sine:: mu, &Diff_sine::sig ma>
    (thePath, theDiff_sine);
    >
    However if I don't overload the operator () but just consider a member
    solve function, then using:
    theEu.solve<Dif f_sine, &Diff_sine:: mu, &Diff_sine::sig ma>
    (thePath, theDiff_sine);
    woks fine.
    >
    So the problem is in overloading the operator, but I can't understand
    where I'm wrong.
    >
    Thank you in advance for your help!
    StephQ

    I havent tried the code but just off the back of my mind I recall
    similar problems with the function operator.

    try the following..

    theEu.operator( )<Diff_sine, &Diff_sine:: mu, &Diff_sine::sig ma>
    (thePath, theDiff_sine);

    Comment

    Working...