From: wolf Date: Tue, 3 Jul 2001 12:31:06 +0000 (+0000) Subject: We may not be allowed to initialize Null-references directly, but we can initialize... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=902e5783c7ffbfd3dee43f24ebf54bca04bd1abb;p=dealii-svn.git We may not be allowed to initialize Null-references directly, but we can initialize them by dereferencing Null pointers. git-svn-id: https://svn.dealii.org/trunk@4807 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/source/thread_management.cc b/deal.II/base/source/thread_management.cc index 8b1430eea2..756f08f0b0 100644 --- a/deal.II/base/source/thread_management.cc +++ b/deal.II/base/source/thread_management.cc @@ -114,7 +114,8 @@ namespace Threads // present. return dummy value // instead Assert (false, ExcNotImplemented()); - return *static_cast(0); + const FunEncapsulation * const p = 0; + return *p; }; diff --git a/deal.II/deal.II/include/numerics/vectors.h b/deal.II/deal.II/include/numerics/vectors.h index 17d34967dd..7b97842570 100644 --- a/deal.II/deal.II/include/numerics/vectors.h +++ b/deal.II/deal.II/include/numerics/vectors.h @@ -407,6 +407,10 @@ class VectorTools * of the previous function for * 1d. At present, it is not * implemented. + * + * The default value of the + * quadrature formula is an + * invalid object. */ static void project (const Mapping<1> &mapping, const DoFHandler<1> &dof, @@ -415,7 +419,7 @@ class VectorTools const Function<1> &function, Vector &vec, const bool enforce_zero_boundary = false, - const Quadrature<0> &q_boundary = *static_cast*>(0), + const Quadrature<0> &q_boundary = *invalid_face_quadrature, const bool project_to_boundary_first = false); /** @@ -797,7 +801,15 @@ class VectorTools /** * Exception */ - DeclException0 (ExcNonInterpolatingFE); + DeclException0 (ExcNonInterpolatingFE); + + private: + /** + * Null pointer used to + * denote invalid face + * quadrature formulas in 1d. + */ + static const Quadrature<0> * const invalid_face_quadrature; }; diff --git a/deal.II/deal.II/source/numerics/error_estimator.cc b/deal.II/deal.II/source/numerics/error_estimator.cc index 5f2c29f46e..9d2a56849a 100644 --- a/deal.II/deal.II/source/numerics/error_estimator.cc +++ b/deal.II/deal.II/source/numerics/error_estimator.cc @@ -49,6 +49,19 @@ double sqr (const double x) #if deal_II_dimension == 1 +// provide zero pointers to be used in the initialization of +// invalid references +namespace +{ + const Mapping<1> * const invalid_mapping = 0; + const DoFHandler<1> * const invalid_dof_handler = 0; + const Quadrature<0> * const invalid_face_quadrature = 0; + const FunctionMap<1>::type * const invalid_function_map = 0; + const std::vector *> * const invalid_solutions = 0; + KellyErrorEstimator<1>::FaceIntegrals * const invalid_face_integrals = 0; +} + + template <> KellyErrorEstimator<1>::Data::Data(const Mapping<1> &, const DoFHandler<1> &, @@ -59,14 +72,14 @@ KellyErrorEstimator<1>::Data::Data(const Mapping<1> &, const Function<1> *, const unsigned int , FaceIntegrals &): - mapping(* static_cast *> (0)), - dof_handler(* static_cast *> (0)), - quadrature(* static_cast *> (0)), - neumann_bc(* static_cast ::type *> (0)), - solutions(* static_cast *> *> (0)), + mapping(*invalid_mapping), + dof_handler(*invalid_dof_handler), + quadrature(*invalid_face_quadrature), + neumann_bc(*invalid_function_map), + solutions(*invalid_solutions), n_threads (0), n_solution_vectors (0), - face_integrals (* static_cast (0)) + face_integrals (*invalid_face_integrals) { Assert (false, ExcInternalError()); } diff --git a/deal.II/deal.II/source/numerics/vectors.all_dimensions.cc b/deal.II/deal.II/source/numerics/vectors.all_dimensions.cc index 1321f0c471..09bde2bdbb 100644 --- a/deal.II/deal.II/source/numerics/vectors.all_dimensions.cc +++ b/deal.II/deal.II/source/numerics/vectors.all_dimensions.cc @@ -16,6 +16,12 @@ #include + +// allocate storage and initialize static variables +const Quadrature<0> * const VectorTools::invalid_face_quadrature = 0; + + + void VectorTools::subtract_mean_value(Vector &v, const std::vector &p_select)