]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Function::operator=
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 6 Feb 2003 17:40:57 +0000 (17:40 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 6 Feb 2003 17:40:57 +0000 (17:40 +0000)
git-svn-id: https://svn.dealii.org/trunk@7052 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/function.h
deal.II/base/source/function.cc
deal.II/doc/news/2002/c-3-4.html

index 0232847d8fbf819f89977414a1b7480e25aa7171..90349aaf96a9080edae774a17a65abea6f5b6c81 100644 (file)
@@ -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.");
 };
 
 
index 8d3308e383750a93e1af8ef999e5fca2dad0855c..fd46e617930e4886021727d3678df036f1dcf0b9 100644 (file)
@@ -31,6 +31,16 @@ Function<dim>::~Function ()
 {}
 
 
+
+template <int dim>
+Function<dim> & Function<dim>::operator= (const Function &f)
+{
+  Assert (n_components == f.n_components,
+          ExcNumberOfComponents(n_components,f.n_components));
+  return *this;
+}
+
+
 template <int dim>
 double Function<dim>::value (const Point<dim> &,
                             const unsigned int) const
index ced17809a8ad46e332194fb5135b8caf5e26ae97..6d05177f15c870d6aa4a809ceeb42ceb976674a7 100644 (file)
@@ -282,6 +282,15 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK
 <h3>base</h3>
 
 <ol>
+  <li> <p> 
+       New: The <code class="class">Function</code> 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.
+       <br>
+       (WB 2003/02/06)
+       </p>
+
   <li> <p> 
        Fixed: The <code class="class">PosixThreadManager</code> called
        its <code class="member">wait</code> function in the

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.