From 5644611dfd9e330f6d5b8df7825eedd92134707c Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Wed, 15 May 2013 21:32:32 +0200 Subject: [PATCH] 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. --- CMakeLists_files.cmake | 1 + opm/core/simulator/SimulatorIncompTwophase.hpp | 6 +++--- opm/core/simulator/SimulatorIncompTwophase_impl.hpp | 12 ++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 opm/core/simulator/SimulatorIncompTwophase_impl.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index ef6f24d9..7405a869 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -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 diff --git a/opm/core/simulator/SimulatorIncompTwophase.hpp b/opm/core/simulator/SimulatorIncompTwophase.hpp index b2595cc1..ccacd3b9 100644 --- a/opm/core/simulator/SimulatorIncompTwophase.hpp +++ b/opm/core/simulator/SimulatorIncompTwophase.hpp @@ -115,9 +115,7 @@ namespace Opm /// sim.run (...); /// \endcode template - void connect_timestep (T& t) { - connect_timestep_impl (boost::function0 (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 diff --git a/opm/core/simulator/SimulatorIncompTwophase_impl.hpp b/opm/core/simulator/SimulatorIncompTwophase_impl.hpp new file mode 100644 index 00000000..a3abc36b --- /dev/null +++ b/opm/core/simulator/SimulatorIncompTwophase_impl.hpp @@ -0,0 +1,12 @@ +#ifndef OPM_SIMULATORINCOMPTWOPHASE_HEADER_INCLUDED +#error Do not include SimulatorIncompTwophase directly! +#endif + +namespace Opm { + +template +inline void SimulatorIncompTwophase::connect_timestep (T& t) { + connect_timestep_impl (boost::function0 (std::bind (callback, t))); +} + +} /* namespace Opm */