10 #ifndef IFPACK2_DETAILS_GETPARAMTRYINGTYPES_HPP
11 #define IFPACK2_DETAILS_GETPARAMTRYINGTYPES_HPP
13 #include "Ifpack2_config.h"
20 template<
class ... CandidateTypes>
21 struct GetParamTryingTypes {
22 template<
class ResultType>
24 get (ResultType& result,
26 const std::string& paramName,
31 struct GetParamTryingTypes<> {
32 template<
class ResultType>
36 const std::string& paramName,
41 (
true, std::invalid_argument, prefix <<
"\"" << paramName
42 <<
"\" parameter exists in input ParameterList, but does not "
43 "have the right type. The proper type is "
44 << TypeNameTraits<ResultType>::name () <<
".");
48 template<
class First,
class ... Rest>
49 struct GetParamTryingTypes<First, Rest...> {
50 template<
class ResultType>
52 get (ResultType& result,
54 const std::string& paramName,
57 if (ent.template isType<First> ()) {
58 result =
static_cast<ResultType
> (Teuchos::getValue<First> (ent));
61 using rest_type = GetParamTryingTypes<Rest...>;
62 rest_type::template get<ResultType> (result, ent, paramName, prefix);
67 template<
class ResultType,
class ... CandidateTypes>
69 getParamTryingTypes (ResultType& result,
71 const std::string& paramName,
75 const ParameterEntry* ent = params.
getEntryPtr (paramName);
77 using impl_type = GetParamTryingTypes<CandidateTypes...>;
78 impl_type::template get<ResultType> (result, *ent, paramName, prefix);
85 #endif // IFPACK2_DETAILS_GETPARAMTRYINGTYPES_HPP
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
ParameterEntry * getEntryPtr(const std::string &name)