From 12f2084c6ce0670a7b470aa1157bab02de31c294 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Sat, 23 Feb 2019 18:09:57 +0100 Subject: [PATCH] add has_begin detector --- include/deal.II/matrix_free/fe_evaluation.h | 21 +++++++++++++++++++ .../matrix_free/fe_evaluation_type_traits.cc | 9 ++++++++ ...tion_type_traits.with_trilinos=true.output | 3 +++ 3 files changed, 33 insertions(+) diff --git a/include/deal.II/matrix_free/fe_evaluation.h b/include/deal.II/matrix_free/fe_evaluation.h index 8da043d70b..4b088f977d 100644 --- a/include/deal.II/matrix_free/fe_evaluation.h +++ b/include/deal.II/matrix_free/fe_evaluation.h @@ -3450,6 +3450,27 @@ namespace internal }; + + // same as above to check + // T::const_iterator T::begin() const + template + struct has_begin + { + private: + static void + detect(...); + + template + static decltype(std::declval().begin()) + detect(const U &); + + public: + static constexpr bool value = + std::is_same()))>::value; + }; + + // access to generic vectors that have operator (). // FIXME: this is wrong for Trilinos/Petsc MPI vectors template ::value << std::endl; + // check has_begin(): + deallog + << "has_begin:" << std::endl + << "LinearAlgebra::distributed::Vector = " + << internal::has_begin>::value + << std::endl + << "TrilinosWrappers::MPI::Vector = " + << internal::has_begin::value << std::endl; + deallog << "OK" << std::endl; } diff --git a/tests/matrix_free/fe_evaluation_type_traits.with_trilinos=true.output b/tests/matrix_free/fe_evaluation_type_traits.with_trilinos=true.output index 4e82d52202..71bac87207 100644 --- a/tests/matrix_free/fe_evaluation_type_traits.with_trilinos=true.output +++ b/tests/matrix_free/fe_evaluation_type_traits.with_trilinos=true.output @@ -10,4 +10,7 @@ DEAL::Dummy2::operator() DEAL::has_partitioners_are_compatible: DEAL::LinearAlgebra::distributed::Vector = 1 DEAL::TrilinosWrappers::MPI::Vector = 0 +DEAL::has_begin: +DEAL::LinearAlgebra::distributed::Vector = 1 +DEAL::TrilinosWrappers::MPI::Vector = 1 DEAL::OK -- 2.39.5