From: wolf Date: Thu, 6 Feb 2003 17:40:57 +0000 (+0000) Subject: Function::operator= X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1064997aa6c60dd97dfc43d3f0588177362a90d;p=dealii-svn.git Function::operator= git-svn-id: https://svn.dealii.org/trunk@7052 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/function.h b/deal.II/base/include/base/function.h index 0232847d8f..90349aaf96 100644 --- a/deal.II/base/include/base/function.h +++ b/deal.II/base/include/base/function.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002 by the deal authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 by the deal authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -158,6 +158,20 @@ class Function : public FunctionTime, = 0 #endif ; + + /** + * Assignment operator. This is + * here only so that you can have + * objects of derived classes in + * containers, or assign them + * otherwise. It will raise an + * exception if the object from + * which you assign has a + * different number of components + * than the one being assigned + * to. + */ + Function & operator= (const Function &f); /** * Return the value of the @@ -311,6 +325,16 @@ class Function : public FunctionTime, * value. */ unsigned int memory_consumption () const; + + /** + * Exception + */ + DeclException2 (ExcNumberOfComponents, + int, int, + << "You can only assign function objects with the same " + << "number of components. However, here the left operand " + << "has " << arg1 << " components, and the right operand " + << arg2 << " components."); }; diff --git a/deal.II/base/source/function.cc b/deal.II/base/source/function.cc index 8d3308e383..fd46e61793 100644 --- a/deal.II/base/source/function.cc +++ b/deal.II/base/source/function.cc @@ -31,6 +31,16 @@ Function::~Function () {} + +template +Function & Function::operator= (const Function &f) +{ + Assert (n_components == f.n_components, + ExcNumberOfComponents(n_components,f.n_components)); + return *this; +} + + template double Function::value (const Point &, const unsigned int) const diff --git a/deal.II/doc/news/2002/c-3-4.html b/deal.II/doc/news/2002/c-3-4.html index ced17809a8..6d05177f15 100644 --- a/deal.II/doc/news/2002/c-3-4.html +++ b/deal.II/doc/news/2002/c-3-4.html @@ -282,6 +282,15 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK

base

    +
  1. + New: The Function class now has an assignment + operator. This way, you can put function objects into + containers. However, the assignment operator makes sure that only + objects can be assigned that have the same number of vector components. +
    + (WB 2003/02/06) +

    +
  2. Fixed: The PosixThreadManager called its wait function in the