template <typename T>
const bool has_local_element<T>::value;
+
+
+ // a helper type-trait that leverage SFINAE to figure out if type T has
+ // void T::add_local_element(const uint, const typename T::value_type)
+ template <typename T>
+ struct has_add_local_element
+ {
+ private:
+ static int
+ detect(...);
+
+ template <typename U>
+ static decltype(
+ std::declval<U>().add_local_element(0, typename T::value_type()))
+ detect(const U &);
+
+ public:
+ static const bool value =
+ !std::is_same<int, decltype(detect(std::declval<T>()))>::value;
+ };
+
+ // We need to have a separate declaration for static const members
+ template <typename T>
+ const bool has_add_local_element<T>::value;
+
+
+
+ // a helper type-trait that leverage SFINAE to figure out if type T has
+ // void T::set_local_element(const uint, const typename T::value_type)
+ template <typename T>
+ struct has_set_local_element
+ {
+ private:
+ static int
+ detect(...);
+
+ template <typename U>
+ static decltype(
+ std::declval<U>().set_local_element(0, typename T::value_type()))
+ detect(const U &);
+
+ public:
+ static const bool value =
+ !std::is_same<int, decltype(detect(std::declval<T>()))>::value;
+ };
+
+ // We need to have a separate declaration for static const members
+ template <typename T>
+ const bool has_set_local_element<T>::value;
+
+
+
// same as above to check
// bool T::partitioners_are_compatible(const Utilities::MPI::Partitioner &)
// const
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2019 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+
+// test internal typetraits used in FEEvaluation
+
+#include <deal.II/matrix_free/fe_evaluation.h>
+
+#include "../tests.h"
+
+// dummy class we use to check typetraits and internal function.
+// this one mimics LA::d::Vec
+template <typename Number>
+class Dummy
+{
+public:
+ using value_type = Number;
+
+ Number
+ local_element(const unsigned int) const
+ {
+ deallog << "Dummy::local_element() const" << std::endl;
+ return Number();
+ }
+
+ void
+ set_local_element(const unsigned int, const Number)
+ {
+ deallog << "Dummy::set_local_element()" << std::endl;
+ }
+
+ void
+ add_local_element(const unsigned int, const Number)
+ {
+ deallog << "Dummy::add_local_element()" << std::endl;
+ }
+
+ Number
+ operator()(const unsigned int) const
+ {
+ deallog << "Dummy::operator() const" << std::endl;
+ return Number();
+ }
+};
+
+
+template <typename Number>
+class Dummy2
+{
+public:
+ using value_type = Number;
+
+ Number
+ local_element(const unsigned int) const
+ {
+ deallog << "Dummy2::local_element() const" << std::endl;
+ return Number();
+ }
+
+ Number &
+ local_element(const unsigned int)
+ {
+ deallog << "Dummy2::local_element()" << std::endl;
+ return dummy;
+ }
+
+ Number
+ operator()(const unsigned int) const
+ {
+ deallog << "Dummy2::operator() const" << std::endl;
+ return Number();
+ }
+
+ Number &
+ operator()(const unsigned int)
+ {
+ deallog << "Dummy2::operator()" << std::endl;
+ return dummy;
+ }
+
+private:
+ Number dummy;
+};
+
+
+int
+main()
+{
+ initlog();
+
+ Dummy<double> dummy;
+ Dummy2<double> dummy2;
+
+ deallog << "has_add_local_element:" << std::endl
+ << "Dummy = " << internal::has_add_local_element<Dummy<double>>::value
+ << std::endl
+ << "Dummy2 = "
+ << internal::has_add_local_element<Dummy2<double>>::value << std::endl
+ << "has_set_local_element:" << std::endl
+ << "Dummy = " << internal::has_set_local_element<Dummy<double>>::value
+ << std::endl
+ << "Dummy2 = "
+ << internal::has_set_local_element<Dummy2<double>>::value
+ << std::endl;
+
+ deallog << "OK" << std::endl;
+}