From: Wolfgang Bangerth Date: Fri, 14 May 2004 15:54:46 +0000 (+0000) Subject: Add an assertion. X-Git-Tag: v8.0.0~15181 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a37f28060606e83bee626e2610e2acf5af039681;p=dealii.git Add an assertion. git-svn-id: https://svn.dealii.org/trunk@9241 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/function.h b/deal.II/base/include/base/function.h index 93c20a0c3d..bbddaaeb89 100644 --- a/deal.II/base/include/base/function.h +++ b/deal.II/base/include/base/function.h @@ -343,6 +343,13 @@ class Function : public FunctionTime, << "number of components. However, here the left operand " << "has " << arg1 << " components, and the right operand " << arg2 << " components."); + /** + * Exception + */ + DeclException1 (ExcInvalidNumberOfComponents, + int, + << "The number of components of a function object must " + << "at least be one, but you gave " << arg1); }; diff --git a/deal.II/base/source/function.cc b/deal.II/base/source/function.cc index d5cccf91a4..2c7dca438e 100644 --- a/deal.II/base/source/function.cc +++ b/deal.II/base/source/function.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 @@ -28,7 +28,16 @@ Function::Function (const unsigned int n_components, : FunctionTime(initial_time), n_components(n_components) -{} +{ + // avoid the construction of function + // objects that don't return any + // values. This doesn't make much sense in + // the first place, but will lead to odd + // errors later on (happened to me in fact + // :-) + Assert (n_components > 0, + ExcInvalidNumberOfComponents(n_components)); +} template