From 871ba0249dd3993d0ef7ad6d84ce875fade8b138 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 23 Nov 2020 18:24:03 -0700 Subject: [PATCH] Simplify some code with stuff from later C++ standards. No need to re-invent wheels. It would be nice if we could have used std::is_base_of, but that doesn't work because we don't know for sure which ones of the possible BlockVectorBase classes is the right base class, given that we don't know T. --- include/deal.II/lac/block_vector_base.h | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/include/deal.II/lac/block_vector_base.h b/include/deal.II/lac/block_vector_base.h index 8404da17b2..870a6ae635 100644 --- a/include/deal.II/lac/block_vector_base.h +++ b/include/deal.II/lac/block_vector_base.h @@ -32,6 +32,7 @@ #include #include #include +#include #include DEAL_II_NAMESPACE_OPEN @@ -65,28 +66,19 @@ template struct IsBlockVector { private: - struct yes_type - { - char c[1]; - }; - struct no_type - { - char c[2]; - }; - /** * Overload returning true if the class is derived from BlockVectorBase, * which is what block vectors do. */ template - static yes_type + static std::true_type check_for_block_vector(const BlockVectorBase *); /** * Catch all for all other potential vector types that are not block * matrices. */ - static no_type + static std::false_type check_for_block_vector(...); public: @@ -96,8 +88,8 @@ public: * derived from BlockVectorBase). */ static const bool value = - (sizeof(check_for_block_vector(static_cast(nullptr))) == - sizeof(yes_type)); + std::is_same())), + std::true_type>::value; }; -- 2.39.5