From 7fab21900b43414bc6d76cc09d907c58752103c0 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Tue, 8 Sep 2015 11:04:55 -0500 Subject: [PATCH] Bugfix: Disallow templated constructor/copy assignment for derived classes --- include/deal.II/lac/linear_operator.h | 13 ++++++++----- tests/lac/block_linear_operator_01.cc | 7 +++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/include/deal.II/lac/linear_operator.h b/include/deal.II/lac/linear_operator.h index bc09bbf58d..2b4808d403 100644 --- a/include/deal.II/lac/linear_operator.h +++ b/include/deal.II/lac/linear_operator.h @@ -22,8 +22,9 @@ #ifdef DEAL_II_WITH_CXX11 -#include #include +#include +#include DEAL_II_NAMESPACE_OPEN @@ -169,11 +170,12 @@ public: LinearOperator (const LinearOperator &) = default; /** - * Templated copy constructor that creates a LinearOperator object from an - * object @p op for which the conversion function + * Templated copy constructor that creates a LinearOperator object from + * an object @p op for which the conversion function * linear_operator is defined. */ - template + template, Op>::value>::type> LinearOperator (const Op &op) { *this = linear_operator(op); @@ -189,7 +191,8 @@ public: * Templated copy assignment operator for an object @p op for which the * conversion function linear_operator is defined. */ - template + template , Op>::value>::type> LinearOperator &operator=(const Op &op) { *this = linear_operator(op); diff --git a/tests/lac/block_linear_operator_01.cc b/tests/lac/block_linear_operator_01.cc index 1d4d6149a4..5c4e033f2c 100644 --- a/tests/lac/block_linear_operator_01.cc +++ b/tests/lac/block_linear_operator_01.cc @@ -112,6 +112,13 @@ int main() }; auto op_b = block_operator<2, 2, BlockVector>(temp); + { + // also test copy and reference assignment to a LinearOperator + LinearOperator> &op_x1 = op_b; + LinearOperator> op_x2 = op_b; + LinearOperator> op_x3(op_b); + } + // vmult: BlockVector u; -- 2.39.5