From: Wolfgang Bangerth Date: Tue, 24 Nov 2020 01:24:03 +0000 (-0700) Subject: Simplify some code with stuff from later C++ standards. X-Git-Tag: v9.3.0-rc1~860^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=871ba0249dd3993d0ef7ad6d84ce875fade8b138;p=dealii.git 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. --- 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; };