From: Wolfgang Bangerth Date: Tue, 3 Feb 2004 14:54:53 +0000 (+0000) Subject: In some situations, the C++ standard requires a copy constructor to be accessible... X-Git-Tag: v8.0.0~15856 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02ef8bb0cb8fb33f940e6523b9ee001e329d6204;p=dealii.git In some situations, the C++ standard requires a copy constructor to be accessible even if it is not used. In particular, this holds when one creates a temporary object and binds it to a const reference. In this case, the compiler will usually bind the temporary directly to the reference, but a copy constructor will still have to be accessible. An example is f(FE_Q(2)). To allow this to compile, we need to make copy constructors accessible, but if they are actually called, we simply throw an exception. git-svn-id: https://svn.dealii.org/trunk@8384 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/fe/fe.h b/deal.II/deal.II/include/fe/fe.h index fcbe0e078b..aaff9e3621 100644 --- a/deal.II/deal.II/include/fe/fe.h +++ b/deal.II/deal.II/include/fe/fe.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -55,13 +55,23 @@ template class FESystem; template class FiniteElement : public FiniteElementBase { - private: - /** - * Copy constructor prohibited. - */ - FiniteElement(const FESystem&); - public: + /** + * Copy constructor. This one is declared + * as a public constructor to avoid + * certain compiler errors when a copy + * constructor is required even if it is + * not executed (for example when binding + * a temporary object to a constant + * reference). However, if you try to + * actually call it, it will throw an + * exception, since copying finite + * element objects is not really + * supported. If you want to copy such an + * object, use the @p{clone} function. + */ + FiniteElement (const FiniteElement &); + /** * Constructor */ diff --git a/deal.II/deal.II/include/fe/fe_system.h b/deal.II/deal.II/include/fe/fe_system.h index 29ffd66bf7..3cdc39eb96 100644 --- a/deal.II/deal.II/include/fe/fe_system.h +++ b/deal.II/deal.II/include/fe/fe_system.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -71,11 +71,6 @@ template class FESystem : public FiniteElement { - /** - * Copy constructor prohibited. - */ - FESystem(const FESystem&); - public: /** diff --git a/deal.II/deal.II/source/fe/fe.cc b/deal.II/deal.II/source/fe/fe.cc index eabd70b3bd..dd9c5f779b 100644 --- a/deal.II/deal.II/source/fe/fe.cc +++ b/deal.II/deal.II/source/fe/fe.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -621,7 +621,8 @@ compute_n_nonzero_components (const std::vector > &nonzero_com template FiniteElement::FiniteElement (const FiniteElementData &fe_data, const std::vector &restriction_is_additive_flags, - const std::vector > &nonzero_components) : + const std::vector > &nonzero_components) + : FiniteElementBase (fe_data, restriction_is_additive_flags, nonzero_components) @@ -629,6 +630,22 @@ FiniteElement::FiniteElement (const FiniteElementData &fe_data, +template +FiniteElement::FiniteElement (const FiniteElement &) + : + FiniteElementBase (FiniteElementData(), + std::vector (), + std::vector >()) +{ + Assert (false, + ExcMessage ("Finite element objects don't support copying " + "semantics through the copy constructor. If " + "you want to copy a finite element, use the " + "clone() function.")); +} + + + template FiniteElement::~FiniteElement () {}