Provide template functions in separate header

Template functions must be defined in the header since the library
cannot contain generic code. To keep only the interface in the main
header, all such function bodies are put in a separate _impl file.
This commit is contained in:
Roland Kaufmann 2013-05-15 21:32:32 +02:00
parent 05636c70c7
commit 5644611dfd
3 changed files with 16 additions and 3 deletions

View File

@ -266,6 +266,7 @@ list (APPEND PUBLIC_HEADER_FILES
opm/core/simulator/BlackoilState.hpp
opm/core/simulator/SimulatorCompressibleTwophase.hpp
opm/core/simulator/SimulatorIncompTwophase.hpp
opm/core/simulator/SimulatorIncompTwophase_impl.hpp
opm/core/simulator/SimulatorReport.hpp
opm/core/simulator/SimulatorTimer.hpp
opm/core/simulator/TwophaseState.hpp

View File

@ -115,9 +115,7 @@ namespace Opm
/// sim.run (...);
/// \endcode
template <typename T, void (T::*callback)()>
void connect_timestep (T& t) {
connect_timestep_impl (boost::function0<void> (std::bind (callback, t)));
}
void connect_timestep (T& t);
private:
class Impl;
@ -130,4 +128,6 @@ namespace Opm
} // namespace Opm
#include "SimulatorIncompTwophase_impl.hpp"
#endif // OPM_SIMULATORINCOMPTWOPHASE_HEADER_INCLUDED

View File

@ -0,0 +1,12 @@
#ifndef OPM_SIMULATORINCOMPTWOPHASE_HEADER_INCLUDED
#error Do not include SimulatorIncompTwophase directly!
#endif
namespace Opm {
template <typename T, void (T::*callback)()>
inline void SimulatorIncompTwophase::connect_timestep (T& t) {
connect_timestep_impl (boost::function0<void> (std::bind (callback, t)));
}
} /* namespace Opm */