41 #ifndef IFPACK2_DETAILS_GETPARAMTRYINGTYPES_HPP
42 #define IFPACK2_DETAILS_GETPARAMTRYINGTYPES_HPP
44 #include "Ifpack2_config.h"
51 template<
class ... CandidateTypes>
52 struct GetParamTryingTypes {
53 template<
class ResultType>
55 get (ResultType& result,
57 const std::string& paramName,
62 struct GetParamTryingTypes<> {
63 template<
class ResultType>
67 const std::string& paramName,
72 (
true, std::invalid_argument, prefix <<
"\"" << paramName
73 <<
"\" parameter exists in input ParameterList, but does not "
74 "have the right type. The proper type is "
75 << TypeNameTraits<ResultType>::name () <<
".");
79 template<
class First,
class ... Rest>
80 struct GetParamTryingTypes<First, Rest...> {
81 template<
class ResultType>
83 get (ResultType& result,
85 const std::string& paramName,
88 if (ent.template isType<First> ()) {
89 result =
static_cast<ResultType
> (Teuchos::getValue<First> (ent));
92 using rest_type = GetParamTryingTypes<Rest...>;
93 rest_type::template get<ResultType> (result, ent, paramName, prefix);
98 template<
class ResultType,
class ... CandidateTypes>
100 getParamTryingTypes (ResultType& result,
102 const std::string& paramName,
106 const ParameterEntry* ent = params.
getEntryPtr (paramName);
107 if (ent !=
nullptr) {
108 using impl_type = GetParamTryingTypes<CandidateTypes...>;
109 impl_type::template get<ResultType> (result, *ent, paramName, prefix);
116 #endif // IFPACK2_DETAILS_GETPARAMTRYINGTYPES_HPP
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
ParameterEntry * getEntryPtr(const std::string &name)