-
Notifications
You must be signed in to change notification settings - Fork 58
Closed
Description
The following code fails to compile:
// Symplectic harmonic oscillator example
{
double t( 0.0 ) , dt( 0.1 );
//[ symplectic_stepper_detail_example
pair< vector_type , vector_type > x;
x.first[0] = 1.0; x.second[0] = 0.0;
symplectic_rkn_sb3a_mclachlan< vector_type > rkn;
rkn.do_step( make_pair( harm_osc_f1() , harm_osc_f2() ) , x , t , dt );
//]
//[ symplectic_stepper_detail_system_class_example
harm_osc h;
rkn.do_step( make_pair( detail::bind( &harm_osc::f1 , h , _1 , _2 ) , detail::bind( &harm_osc::f2 , h , _1 , _2 ) ) ,
x , t , dt );
//]
}
Because std::placeholders::_1 and _2 are not in scope. The fix is to include <functional> and add using declarations for the placeholders:
// Symplectic harmonic oscillator example
{
using std::placeholders::_1;
using std::placeholders::_2;
double t( 0.0 ) , dt( 0.1 );
//[ symplectic_stepper_detail_example
pair< vector_type , vector_type > x;
x.first[0] = 1.0; x.second[0] = 0.0;
symplectic_rkn_sb3a_mclachlan< vector_type > rkn;
rkn.do_step( make_pair( harm_osc_f1() , harm_osc_f2() ) , x , t , dt );
//]
//[ symplectic_stepper_detail_system_class_example
harm_osc h;
rkn.do_step( make_pair( detail::bind( &harm_osc::f1 , h , _1 , _2 ) , detail::bind( &harm_osc::f2 , h , _1 , _2 ) ) ,
x , t , dt );
//]
}
Pull request to follow...
Metadata
Metadata
Assignees
Labels
No labels