WSJT-X/libs/numeric/odeint/doc/details_boost_ref.qbk
Bill Somerville 4ebe6417a5 Squashed 'boost/' content from commit b4feb19f2
git-subtree-dir: boost
git-subtree-split: b4feb19f287ee92d87a9624b5d36b7cf46aeadeb
2018-06-09 21:48:32 +01:00

36 lines
1.5 KiB
Plaintext

[/============================================================================
Boost.odeint
Copyright 2012 Karsten Ahnert
Copyright 2012 Mario Mulansky
Use, modification and distribution is subject to the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
=============================================================================/]
[section Using boost::ref]
In odeint all system functions and observers are passed by value. For example, if you call a `do_step` method of a particular stepper or the integration functions, your system and your stepper will be passed by value:
[c++]
``
rk4.do_step( sys , x , t , dt ); // pass sys by value
``
This behavior is suitable for most systems, especially if your system does not contain any data or only a few parameters. However, in some cases you might contain some large amount of data with you system function and passing them by value is not desired since the data would be copied.
In such cases you can easily use `boost::ref` (and its relative `boost::cref`)
which passes its argument by reference (or constant reference). odeint will
unpack the arguments and no copying at all of your system object will take place:
``
rk4.do_step( boost::ref( sys ) , x , t , dt ); // pass sys as references
``
The same mechanism can be used for the observers in the integrate functions.
[tip If you are using C++11 you can also use `std::ref` and `std::cref`]
[endsect]