replace custom conditional type selector by std::conditional

I did not know about std::conditional until today...
This commit is contained in:
Andreas Lauser 2015-07-29 13:56:53 +02:00
parent fc2e6c9918
commit 5d2dadc6e1

View File

@ -35,29 +35,9 @@
#include "FluidStateEnthalpyModules.hpp" #include "FluidStateEnthalpyModules.hpp"
#include "ModularFluidState.hpp" #include "ModularFluidState.hpp"
#include <type_traits>
namespace Opm { namespace Opm {
/*!
* \brief This is a helper class to select a type depending on a condition.
*
* This is required for the template-meta-programming-foo of SimpleModularFluidState.
*/
template <bool yesno, class TrueType, class FalseType>
class IfThenElseType;
template <class TrueType, class FalseType>
class IfThenElseType<true, TrueType, FalseType>
{
public:
typedef TrueType type;
};
template <class TrueType, class FalseType>
class IfThenElseType<false, TrueType, FalseType>
{
public:
typedef FalseType type;
};
// this macro is a small hack to prevent death-through verbosity // this macro is a small hack to prevent death-through verbosity
#define OPM_SMFS SimpleModularFluidState<ScalarT, \ #define OPM_SMFS SimpleModularFluidState<ScalarT, \
numPhasesV, \ numPhasesV, \
@ -94,28 +74,28 @@ template <class ScalarT,
bool storeEnthalpy> bool storeEnthalpy>
class SimpleModularFluidState class SimpleModularFluidState
: public ModularFluidState<ScalarT, numPhasesV, numComponentsV, : public ModularFluidState<ScalarT, numPhasesV, numComponentsV,
typename IfThenElseType<storePressure, typename std::conditional<storePressure,
FluidStateExplicitPressureModule<ScalarT, numPhasesV, OPM_SMFS>, FluidStateExplicitPressureModule<ScalarT, numPhasesV, OPM_SMFS>,
FluidStateNullPressureModule<ScalarT> >::type, FluidStateNullPressureModule<ScalarT> >::type,
typename IfThenElseType<storeTemperature, typename std::conditional<storeTemperature,
FluidStateExplicitTemperatureModule<ScalarT, numPhasesV, OPM_SMFS>, FluidStateExplicitTemperatureModule<ScalarT, numPhasesV, OPM_SMFS>,
FluidStateNullTemperatureModule<ScalarT> >::type, FluidStateNullTemperatureModule<ScalarT> >::type,
typename IfThenElseType<storeComposition, typename std::conditional<storeComposition,
FluidStateExplicitCompositionModule<ScalarT, FluidSystem, OPM_SMFS>, FluidStateExplicitCompositionModule<ScalarT, FluidSystem, OPM_SMFS>,
FluidStateNullCompositionModule<ScalarT> >::type, FluidStateNullCompositionModule<ScalarT> >::type,
typename IfThenElseType<storeFugacity, typename std::conditional<storeFugacity,
FluidStateExplicitFugacityModule<ScalarT, numPhasesV, numComponentsV, OPM_SMFS>, FluidStateExplicitFugacityModule<ScalarT, numPhasesV, numComponentsV, OPM_SMFS>,
FluidStateNullFugacityModule<ScalarT> >::type, FluidStateNullFugacityModule<ScalarT> >::type,
typename IfThenElseType<storeSaturation, typename std::conditional<storeSaturation,
FluidStateExplicitSaturationModule<ScalarT, numPhasesV, OPM_SMFS>, FluidStateExplicitSaturationModule<ScalarT, numPhasesV, OPM_SMFS>,
FluidStateNullSaturationModule<ScalarT> >::type, FluidStateNullSaturationModule<ScalarT> >::type,
typename IfThenElseType<storeDensity, typename std::conditional<storeDensity,
FluidStateExplicitDensityModule<ScalarT, numPhasesV, OPM_SMFS>, FluidStateExplicitDensityModule<ScalarT, numPhasesV, OPM_SMFS>,
FluidStateNullDensityModule<ScalarT, numPhasesV, OPM_SMFS> >::type, FluidStateNullDensityModule<ScalarT, numPhasesV, OPM_SMFS> >::type,
typename IfThenElseType<storeViscosity, typename std::conditional<storeViscosity,
FluidStateExplicitViscosityModule<ScalarT, numPhasesV, OPM_SMFS>, FluidStateExplicitViscosityModule<ScalarT, numPhasesV, OPM_SMFS>,
FluidStateNullViscosityModule<ScalarT, numPhasesV, OPM_SMFS> >::type, FluidStateNullViscosityModule<ScalarT, numPhasesV, OPM_SMFS> >::type,
typename IfThenElseType<storeEnthalpy, typename std::conditional<storeEnthalpy,
FluidStateExplicitEnthalpyModule<ScalarT, numPhasesV, OPM_SMFS>, FluidStateExplicitEnthalpyModule<ScalarT, numPhasesV, OPM_SMFS>,
FluidStateNullEnthalpyModule<ScalarT, numPhasesV, OPM_SMFS> >::type FluidStateNullEnthalpyModule<ScalarT, numPhasesV, OPM_SMFS> >::type
> >