10#ifndef IFPACK2_DETAILS_GETPARAMTRYINGTYPES_HPP
11#define IFPACK2_DETAILS_GETPARAMTRYINGTYPES_HPP
13#include "Ifpack2_config.h"
14#include "Teuchos_TypeNameTraits.hpp"
15#include "Teuchos_ParameterList.hpp"
20template <
class... CandidateTypes>
21struct GetParamTryingTypes {
22 template <
class ResultType>
24 get(ResultType& result,
25 const Teuchos::ParameterEntry& ent,
26 const std::string& paramName,
31struct GetParamTryingTypes<> {
32 template <
class ResultType>
35 const Teuchos::ParameterEntry& ,
36 const std::string& paramName,
37 const char prefix[]) {
38 using Teuchos::TypeNameTraits;
39 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::invalid_argument, prefix <<
"\"" << paramName <<
"\" parameter exists in input ParameterList, but does not "
40 "have the right type. The proper type is "
41 << TypeNameTraits<ResultType>::name() <<
".");
45template <
class First,
class... Rest>
46struct GetParamTryingTypes<First, Rest...> {
47 template <
class ResultType>
49 get(ResultType& result,
50 const Teuchos::ParameterEntry& ent,
51 const std::string& paramName,
52 const char prefix[]) {
53 if (ent.template isType<First>()) {
54 result =
static_cast<ResultType
>(Teuchos::getValue<First>(ent));
56 using rest_type = GetParamTryingTypes<Rest...>;
57 rest_type::template get<ResultType>(result, ent, paramName, prefix);
62template <
class ResultType,
class... CandidateTypes>
63void getParamTryingTypes(ResultType& result,
64 const Teuchos::ParameterList& params,
65 const std::string& paramName,
66 const char prefix[]) {
67 using Teuchos::ParameterEntry;
68 const ParameterEntry* ent = params.getEntryPtr(paramName);
70 using impl_type = GetParamTryingTypes<CandidateTypes...>;
71 impl_type::template get<ResultType>(result, *ent, paramName, prefix);
Ifpack2 implementation details.
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:40