From: Wolfgang Bangerth Date: Wed, 25 Nov 2020 02:23:22 +0000 (-0700) Subject: Simplify some code with stuff from later C++ standards. X-Git-Tag: v9.3.0-rc1~851^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c38b1045cc8855d006b3ca8a1d9f7e09bd242d11;p=dealii.git Simplify some code with stuff from later C++ standards. While there also rename a function to better express the intent that we're not just checking for block matrices, but also block sparsity patterns. The class name doesn't currently reflect that, but the documentation now does. --- diff --git a/include/deal.II/lac/affine_constraints.h b/include/deal.II/lac/affine_constraints.h index 5c05f90a54..03169d4b56 100644 --- a/include/deal.II/lac/affine_constraints.h +++ b/include/deal.II/lac/affine_constraints.h @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -2280,11 +2281,11 @@ class BlockSparseMatrixEZ; /** * A class that can be used to determine whether a given type is a block - * matrix type or not. For example, + * matrix or block sparsity pattern type or not. For example, * @code * IsBlockMatrix >::value * @endcode - * has the value false, whereas + * has the value `false`, whereas * @code * IsBlockMatrix >::value * @endcode @@ -2299,56 +2300,48 @@ template struct IsBlockMatrix { private: - struct yes_type - { - char c[1]; - }; - struct no_type - { - char c[2]; - }; - /** * Overload returning true if the class is derived from BlockMatrixBase, * which is what block matrices do (with the exception of * BlockSparseMatrixEZ). */ template - static yes_type - check_for_block_matrix(const BlockMatrixBase *); + static std::true_type + check(const BlockMatrixBase *); /** * Overload returning true if the class is derived from * BlockSparsityPatternBase, which is what block sparsity patterns do. */ template - static yes_type - check_for_block_matrix(const BlockSparsityPatternBase *); + static std::true_type + check(const BlockSparsityPatternBase *); /** * Overload for BlockSparseMatrixEZ, which is the only block matrix not * derived from BlockMatrixBase at the time of writing this class. */ template - static yes_type - check_for_block_matrix(const BlockSparseMatrixEZ *); + static std::true_type + check(const BlockSparseMatrixEZ *); /** * Catch all for all other potential matrix types that are not block * matrices. */ - static no_type - check_for_block_matrix(...); + static std::false_type + check(...); public: /** * A statically computable value that indicates whether the template * argument to this class is a block matrix (in fact whether the type is - * derived from BlockMatrixBase). + * derived from BlockMatrixBase or is one of the other block matrix + * or block sparsity pattern types). */ static const bool value = - (sizeof(check_for_block_matrix(static_cast(nullptr))) == - sizeof(yes_type)); + std::is_same())), + std::true_type>::value; }; // instantiation of the static member