From 2e4ffe5de3021a740186b91b9169e9a5185f7c76 Mon Sep 17 00:00:00 2001 From: wolf Date: Fri, 14 May 2004 15:54:46 +0000 Subject: [PATCH] Add an assertion. git-svn-id: https://svn.dealii.org/trunk@9241 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/function.h | 7 +++++++ deal.II/base/source/function.cc | 13 +++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) 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 -- 2.39.5