title: different way to write a method
body: <p>I have a class to define a right hand side terms of differential equation: 
  this class provide the method to compute the rhs function and its derivate 
  the function is store in a vector container in this way the class is suitable for the system of Differential Equation as well.</p>
  
  <p>here the interface in which the method that I would to change is defined </p>
  
  <pre><code> template &lt;typename Type = double&gt;
  class rhsODEProblem {
  
         using analysisFunction = std::function&lt;const Type(const Type, const std::valarray&lt;Type&gt;)&gt;;
  
  
     public:
  
  
  
     rhsODEProblem(const std::vector&lt;std::function&lt;const Type(const Type,const std::valarray&lt;Type&gt;)&gt;&gt; numfun ,
                    const std::vector&lt;std::function&lt;const Type(const Type,const Type)&gt;&gt; exactfun ,
                    const Type,const Type,const Type,const std::valarray&lt;Type&gt;,const std::string ) noexcept ;
  
  
     rhsODEProblem(const std::vector&lt;std::function&lt;const Type(const Type,const std::valarray&lt;Type&gt;)&gt;&gt; numfun,
                   const Type, const Type, const Type, const std::valarray&lt;Type&gt; ) noexcept ;
  
  
        virtual ~rhsODEProblem() = default ;
  
        rhsODEProblem(const rhsODEProblem &amp;) = default ;
        rhsODEProblem(rhsODEProblem&amp;&amp; ) = default ;
        rhsODEProblem&amp; operator=(const rhsODEProblem&amp;) = default ;
        rhsODEProblem&amp; operator=(rhsODEProblem&amp;&amp; ) = default ;
  
  
        const std::vector&lt;std::function&lt;const Type(const Type,const std::valarray&lt;Type&gt;)&gt;&gt; numericalFunction ;
  
        const std::vector&lt;std::function&lt;const Type(const Type,const Type)&gt;&gt; analiticalFunction ;
  
  
        const std::vector&lt;analysisFunction&gt;&amp;  f = numericalFunction ;   
  
  
        const auto dfdt(std::size_t indx , const Type t , const std::valarray&lt;Type&gt; u) {
              return (f[indx](t, u+eps )-f[indx](t,u))/eps ;
        }   
  
  
        auto setRhs (const std::vector&lt;
                     std::function&lt;const Type(const Type,const std::valarray&lt;Type&gt;)&gt;&gt; numfun) noexcept
        {     
  
          for(auto i=0 ; i &lt; numfun.size() ; i++)
          {
            numericalFunction.push_back(numfun.at(i)) ; 
          }  
        } 
  
        auto setExact(const std::vector&lt;std::function&lt;const Type(const Type,const Type)&gt;&gt; exactfun) noexcept
        {
            for(auto i=0 ; i &lt; exactfun.size(); i++)
            {
              analiticalFunction.push_back(exactfun.at(i));
            }  
        }
  
        auto solveExact() noexcept ;
  
        const Type t0() const noexcept { return _t0 ;} 
        const Type tf() const noexcept { return _tf ;}
        const Type dt() const noexcept { return _dt ;}
        const std::valarray&lt;Type&gt; u0() const noexcept { return _u0 ;}
        const std::string fname ()     const noexcept { return filename ;}
  
  
  //---
     private:
  
                     Type  _t0 ;  // start time
                     Type  _tf ;  // final time
                     Type  _dt ;  // time-step
       std::valarray&lt;Type&gt; _u0 ;  // iv
  
       std::string filename ; 
  
       Type eps  = 1e-12  ; 
  
  
  };
  </code></pre>
  
  <p>I would like to change the method dfdt in a way in which I can call it using the following syntax <code>dfdt[index]( t , u_valarray )</code> instead of <code>dfdt(index, t, u_valarray )</code> 
  In which way I can change this method ?  </p>
  
  <p><strong>EDIT</strong> thank for your answer so in my case it gonna be :</p>
  
  <pre><code>foo_helper(foo &amp;, int index);
            operator()(int n, Type t, std::valarray&lt;Type&gt; u );
  </code></pre>
  
  <p>right ?</p>
  
  <p><strong>EDIT</strong> no I didn't get the point. I wrote :</p>
  
  <pre><code>class dfdx {
          public:
              dfdx( rhsODEProblem&lt;Type&gt; &amp;r , int index_ ) : index{index_ } {}
              void operator()(Type t, std::valarray&lt;Type&gt; u){
                      return (f[index](t, u + eps )-f[index](t,u))/eps ;
              }
          int index ;
    };
  
    dfdx operator[](std::size_t index) {
          return dfdx(*this, index);
    }
  </code></pre>
  
  <p>then I call it in this way : </p>
  
  <pre><code>rhs.dfdx[j](t , uOld) )
  </code></pre>
  
  <p>but I got an error :</p>
  
  <pre><code>BackwardEulerSolver.H:114:50: error: invalid use of ‘class mg::numeric::odesystem::rhsODEProblem&lt;double&gt;::dfdx’
                                    ( 1- dt() * rhs.dfdx[j](t , uOld) ) ;
                                                ~~~~^~~~
  </code></pre>