Using external C++ function in the model block

Could you please explain more? I am using the Stan::math::integrate_1d inside my C++ code which is as below:



template <typename T_a__, typename T_b__,typename T_theta__>
typename boost::math::tools::promote_args <T_a__, T_b__, T_theta__>::type
partC ( const double& a, const double& b, const double beta, const double mu0, const double mu1, const double gamma, const double delta, const double sigma, const double M0, std::ostream& msgs) {
    
     using stan::math::var;
    
   
   
    auto const f2= [&](const double x, const double xc, const std::vector<var> theta,  std::vector<double> x_r, std::vector<int> x_i,  std::ostream& msgs) {
        
        return   ( 0.5 * erfc(-(M0-(theta[1]+theta[2]*exp(- theta[3]* pow((7.0+log(x)),theta[4]))))/(theta[5]*sqrt(2.0))) );
                 
    };
    

    std::vector<double> theta = {beta, mu0, mu1, gamma, delta, sigma};

    var Q = stan::math::integrate_1d(f2, a, b, theta,{},{}, msgs);
     return Q;
    
}
#endif /* tacppnew_hpp */

Are you suggesting to do it that way? Many thanks in advance