From d111634daeb60a29138d2708f782835d467d8d5a Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Wed, 23 Feb 2022 07:12:41 -0600 Subject: [PATCH] Declare a number of static consts as constexpr By changing the underlying type from `static const` to `static constexpr` it is possible to use these dimension constants also in template expressions. --- include/deal.II/base/function.h | 2 +- include/deal.II/base/incremental_function.h | 2 +- include/deal.II/base/polynomial_space.h | 2 +- .../deal.II/base/polynomials_barycentric.h | 2 +- include/deal.II/base/polynomials_p.h | 2 +- include/deal.II/base/polynomials_pyramid.h | 2 +- .../base/polynomials_rannacher_turek.h | 2 +- include/deal.II/base/polynomials_wedge.h | 2 +- include/deal.II/base/symmetric_tensor.h | 2 +- .../deal.II/base/tensor_product_polynomials.h | 2 +- .../base/tensor_product_polynomials_bubbles.h | 2 +- .../base/tensor_product_polynomials_const.h | 2 +- .../deal.II/differentiation/ad/ad_helpers.h | 2 +- include/deal.II/dofs/dof_accessor.h | 8 ++++---- include/deal.II/dofs/dof_handler.h | 4 ++-- include/deal.II/fe/fe.h | 2 +- include/deal.II/fe/fe_base.h | 2 +- include/deal.II/fe/fe_poly.h | 2 +- include/deal.II/fe/fe_values.h | 20 +++++++++---------- include/deal.II/grid/persistent_tria.h | 4 ++-- include/deal.II/grid/tria.h | 4 ++-- include/deal.II/grid/tria_accessor.h | 12 +++++------ include/deal.II/hp/fe_values.h | 4 ++-- include/deal.II/matrix_free/matrix_free.h | 2 +- include/deal.II/meshworker/integration_info.h | 4 ++-- 25 files changed, 47 insertions(+), 47 deletions(-) diff --git a/include/deal.II/base/function.h b/include/deal.II/base/function.h index d252796d41..932ff5afcd 100644 --- a/include/deal.II/base/function.h +++ b/include/deal.II/base/function.h @@ -156,7 +156,7 @@ public: * Export the value of the template parameter as a static member constant. * Sometimes useful for some expression template programming. */ - static const unsigned int dimension = dim; + static constexpr unsigned int dimension = dim; /** * Number of vector components. diff --git a/include/deal.II/base/incremental_function.h b/include/deal.II/base/incremental_function.h index 641cba7109..c3286ce3c8 100644 --- a/include/deal.II/base/incremental_function.h +++ b/include/deal.II/base/incremental_function.h @@ -56,7 +56,7 @@ namespace Functions * Export the value of the template parameter as a static member constant. * This is sometimes useful in the context of template programming. */ - static const unsigned int dimension = dim; + static constexpr unsigned int dimension = dim; /** * The scalar-valued real type used for representing time. diff --git a/include/deal.II/base/polynomial_space.h b/include/deal.II/base/polynomial_space.h index dc1ac3dc81..4193169fb6 100644 --- a/include/deal.II/base/polynomial_space.h +++ b/include/deal.II/base/polynomial_space.h @@ -102,7 +102,7 @@ public: * Access to the dimension of this object, for checking and automatic * setting of dimension in other classes. */ - static const unsigned int dimension = dim; + static constexpr unsigned int dimension = dim; /** * Constructor. pols is a vector of pointers to one-dimensional diff --git a/include/deal.II/base/polynomials_barycentric.h b/include/deal.II/base/polynomials_barycentric.h index 2668640096..eb5fd8564f 100644 --- a/include/deal.II/base/polynomials_barycentric.h +++ b/include/deal.II/base/polynomials_barycentric.h @@ -243,7 +243,7 @@ public: /** * Make the dimension available to the outside. */ - static const unsigned int dimension = dim; + static constexpr unsigned int dimension = dim; /** * Get the standard Lagrange basis for a specified degree. diff --git a/include/deal.II/base/polynomials_p.h b/include/deal.II/base/polynomials_p.h index cc7ef884c3..3e31f277b0 100644 --- a/include/deal.II/base/polynomials_p.h +++ b/include/deal.II/base/polynomials_p.h @@ -51,7 +51,7 @@ public: * Access to the dimension of this object, for checking and automatic * setting of dimension in other classes. */ - static const unsigned int dimension = dim; + static constexpr unsigned int dimension = dim; /** * Constructor. Creates all basis functions of $P_p$. @arg p: the degree of diff --git a/include/deal.II/base/polynomials_pyramid.h b/include/deal.II/base/polynomials_pyramid.h index 0c0ee41a5c..7475cd07eb 100644 --- a/include/deal.II/base/polynomials_pyramid.h +++ b/include/deal.II/base/polynomials_pyramid.h @@ -34,7 +34,7 @@ public: /** * Make the dimension available to the outside. */ - static const unsigned int dimension = dim; + static constexpr unsigned int dimension = dim; /* * Constructor taking the polynomial @p degree as input. diff --git a/include/deal.II/base/polynomials_rannacher_turek.h b/include/deal.II/base/polynomials_rannacher_turek.h index ee5cfad18a..bbc8b16d7e 100644 --- a/include/deal.II/base/polynomials_rannacher_turek.h +++ b/include/deal.II/base/polynomials_rannacher_turek.h @@ -45,7 +45,7 @@ public: /** * Dimension we are working in. */ - static const unsigned int dimension = dim; + static constexpr unsigned int dimension = dim; /** * Constructor, checking that the basis is implemented in this dimension. diff --git a/include/deal.II/base/polynomials_wedge.h b/include/deal.II/base/polynomials_wedge.h index 2cd3a27962..c29410fc0a 100644 --- a/include/deal.II/base/polynomials_wedge.h +++ b/include/deal.II/base/polynomials_wedge.h @@ -40,7 +40,7 @@ public: /** * Make the dimension available to the outside. */ - static const unsigned int dimension = dim; + static constexpr unsigned int dimension = dim; /* * Constructor taking the polynomial @p degree as input. diff --git a/include/deal.II/base/symmetric_tensor.h b/include/deal.II/base/symmetric_tensor.h index 0f0d659d38..9133cc9230 100644 --- a/include/deal.II/base/symmetric_tensor.h +++ b/include/deal.II/base/symmetric_tensor.h @@ -680,7 +680,7 @@ public: * of an inlined function; the compiler may therefore produce more efficient * code and you may use this value to declare other data types. */ - static const unsigned int dimension = dim; + static constexpr unsigned int dimension = dim; /** * Publish the rank of this tensor to the outside world. diff --git a/include/deal.II/base/tensor_product_polynomials.h b/include/deal.II/base/tensor_product_polynomials.h index a8666cc80f..bfa7734561 100644 --- a/include/deal.II/base/tensor_product_polynomials.h +++ b/include/deal.II/base/tensor_product_polynomials.h @@ -80,7 +80,7 @@ public: * Access to the dimension of this object, for checking and automatic * setting of dimension in other classes. */ - static const unsigned int dimension = dim; + static constexpr unsigned int dimension = dim; /** * Constructor. pols is a vector of objects that should be derived diff --git a/include/deal.II/base/tensor_product_polynomials_bubbles.h b/include/deal.II/base/tensor_product_polynomials_bubbles.h index d74f012cf0..bd472af5c0 100644 --- a/include/deal.II/base/tensor_product_polynomials_bubbles.h +++ b/include/deal.II/base/tensor_product_polynomials_bubbles.h @@ -57,7 +57,7 @@ public: * Access to the dimension of this object, for checking and automatic * setting of dimension in other classes. */ - static const unsigned int dimension = dim; + static constexpr unsigned int dimension = dim; /** * Constructor. pols is a vector of objects that should be derived diff --git a/include/deal.II/base/tensor_product_polynomials_const.h b/include/deal.II/base/tensor_product_polynomials_const.h index 62bccbf706..62d1655e1d 100644 --- a/include/deal.II/base/tensor_product_polynomials_const.h +++ b/include/deal.II/base/tensor_product_polynomials_const.h @@ -50,7 +50,7 @@ public: * Access to the dimension of this object, for checking and automatic * setting of dimension in other classes. */ - static const unsigned int dimension = dim; + static constexpr unsigned int dimension = dim; /** * Constructor. pols is a vector of objects that should be derived diff --git a/include/deal.II/differentiation/ad/ad_helpers.h b/include/deal.II/differentiation/ad/ad_helpers.h index f10042a429..2cc9249453 100644 --- a/include/deal.II/differentiation/ad/ad_helpers.h +++ b/include/deal.II/differentiation/ad/ad_helpers.h @@ -2646,7 +2646,7 @@ namespace Differentiation * Type definition for the dimension of the associated input and output * tensor types. */ - static const unsigned int dimension = dim; + static constexpr unsigned int dimension = dim; /** * Type definition for the floating point number type that is used in, diff --git a/include/deal.II/dofs/dof_accessor.h b/include/deal.II/dofs/dof_accessor.h index 0ccf0c8369..39ee53ef31 100644 --- a/include/deal.II/dofs/dof_accessor.h +++ b/include/deal.II/dofs/dof_accessor.h @@ -216,13 +216,13 @@ public: * A static variable that allows users of this class to discover the value * of the second template argument. */ - static const unsigned int dimension = dim; + static constexpr unsigned int dimension = dim; /** * A static variable that allows users of this class to discover the value * of the third template argument. */ - static const unsigned int space_dimension = spacedim; + static constexpr unsigned int space_dimension = spacedim; /** * Declare an alias to the base class to make accessing some of the @@ -770,13 +770,13 @@ public: * A static variable that allows users of this class to discover the value * of the second template argument. */ - static const unsigned int dimension = 1; + static constexpr unsigned int dimension = 1; /** * A static variable that allows users of this class to discover the value * of the third template argument. */ - static const unsigned int space_dimension = spacedim; + static constexpr unsigned int space_dimension = spacedim; /** * Declare an alias to the base class to make accessing some of the diff --git a/include/deal.II/dofs/dof_handler.h b/include/deal.II/dofs/dof_handler.h index 1752413782..25c6c46c36 100644 --- a/include/deal.II/dofs/dof_handler.h +++ b/include/deal.II/dofs/dof_handler.h @@ -506,12 +506,12 @@ public: /** * Make the dimension available in function templates. */ - static const unsigned int dimension = dim; + static constexpr unsigned int dimension = dim; /** * Make the space dimension available in function templates. */ - static const unsigned int space_dimension = spacedim; + static constexpr unsigned int space_dimension = spacedim; /** * The default index of the finite element to be used on a given cell. diff --git a/include/deal.II/fe/fe.h b/include/deal.II/fe/fe.h index 624b7a244f..388d7c0146 100644 --- a/include/deal.II/fe/fe.h +++ b/include/deal.II/fe/fe.h @@ -656,7 +656,7 @@ public: /** * The dimension of the image space, corresponding to Triangulation. */ - static const unsigned int space_dimension = spacedim; + static constexpr unsigned int space_dimension = spacedim; /** * A base class for internal data that derived finite element classes may diff --git a/include/deal.II/fe/fe_base.h b/include/deal.II/fe/fe_base.h index 5dd296ec5d..f817e16345 100644 --- a/include/deal.II/fe/fe_base.h +++ b/include/deal.II/fe/fe_base.h @@ -283,7 +283,7 @@ public: * The dimension of the finite element, which is the template parameter * dim */ - static const unsigned int dimension = dim; + static constexpr unsigned int dimension = dim; private: /** diff --git a/include/deal.II/fe/fe_poly.h b/include/deal.II/fe/fe_poly.h index b350e68754..9564366d4d 100644 --- a/include/deal.II/fe/fe_poly.h +++ b/include/deal.II/fe/fe_poly.h @@ -42,7 +42,7 @@ DEAL_II_NAMESPACE_OPEN * functions can be used as template parameter @p PolynomialType. * * @code - * static const unsigned int dimension; + * static constexpr unsigned int dimension; * * void evaluate (const Point &unit_point, * std::vector &values, diff --git a/include/deal.II/fe/fe_values.h b/include/deal.II/fe/fe_values.h index 191333295a..bcef903b8d 100644 --- a/include/deal.II/fe/fe_values.h +++ b/include/deal.II/fe/fe_values.h @@ -2415,12 +2415,12 @@ public: /** * Dimension in which this object operates. */ - static const unsigned int dimension = dim; + static constexpr unsigned int dimension = dim; /** * Dimension of the space in which this object operates. */ - static const unsigned int space_dimension = spacedim; + static constexpr unsigned int space_dimension = spacedim; /** * Number of quadrature points of the current object. Its value is @@ -4048,7 +4048,7 @@ public: * Dimension of the object over which we integrate. For the present class, * this is equal to dim. */ - static const unsigned int integral_dimension = dim; + static constexpr unsigned int integral_dimension = dim; /** * Constructor. Gets cell independent data from mapping and finite element @@ -4187,7 +4187,7 @@ public: * Dimension of the object over which we integrate. For the present class, * this is equal to dim-1. */ - static const unsigned int integral_dimension = dim - 1; + static constexpr unsigned int integral_dimension = dim - 1; /** * Constructor. Call the constructor of the base class and set up the arrays @@ -4307,15 +4307,15 @@ public: * Dimension in which this object operates. */ - static const unsigned int dimension = dim; + static constexpr unsigned int dimension = dim; - static const unsigned int space_dimension = spacedim; + static constexpr unsigned int space_dimension = spacedim; /** * Dimension of the object over which we integrate. For the present class, * this is equal to dim-1. */ - static const unsigned int integral_dimension = dim - 1; + static constexpr unsigned int integral_dimension = dim - 1; /** * Constructor. Gets cell independent data from mapping and finite element @@ -4472,18 +4472,18 @@ public: /** * Dimension in which this object operates. */ - static const unsigned int dimension = dim; + static constexpr unsigned int dimension = dim; /** * Dimension of the space in which this object operates. */ - static const unsigned int space_dimension = spacedim; + static constexpr unsigned int space_dimension = spacedim; /** * Dimension of the object over which we integrate. For the present class, * this is equal to dim-1. */ - static const unsigned int integral_dimension = dim - 1; + static constexpr unsigned int integral_dimension = dim - 1; /** * Constructor. Gets cell independent data from mapping and finite element diff --git a/include/deal.II/grid/persistent_tria.h b/include/deal.II/grid/persistent_tria.h index f5e45cc585..05e8448157 100644 --- a/include/deal.II/grid/persistent_tria.h +++ b/include/deal.II/grid/persistent_tria.h @@ -111,8 +111,8 @@ public: /** * Make the dimension available in function templates. */ - static const unsigned int dimension = dim; - static const unsigned int spacedimension = spacedim; + static constexpr unsigned int dimension = dim; + static const unsigned int spacedimension = spacedim; /** * Build up the triangulation from the coarse grid in future. Copy smoothing diff --git a/include/deal.II/grid/tria.h b/include/deal.II/grid/tria.h index 8814bc8159..9dc1d8c3c9 100644 --- a/include/deal.II/grid/tria.h +++ b/include/deal.II/grid/tria.h @@ -1539,12 +1539,12 @@ public: /** * Make the dimension available in function templates. */ - static const unsigned int dimension = dim; + static constexpr unsigned int dimension = dim; /** * Make the space-dimension available in function templates. */ - static const unsigned int space_dimension = spacedim; + static constexpr unsigned int space_dimension = spacedim; /** * Create an empty triangulation. Do not create any cells. diff --git a/include/deal.II/grid/tria_accessor.h b/include/deal.II/grid/tria_accessor.h index 7134de41d3..3f33902091 100644 --- a/include/deal.II/grid/tria_accessor.h +++ b/include/deal.II/grid/tria_accessor.h @@ -306,14 +306,14 @@ public: * For example, if this accessor represents a quad that is part of a two- * dimensional surface in four-dimensional space, then this value is four. */ - static const unsigned int space_dimension = spacedim; + static constexpr unsigned int space_dimension = spacedim; /** * Dimensionality of the object that the thing represented by this accessor * is part of. For example, if this accessor represents a line that is part * of a hexahedron, then this value will be three. */ - static const unsigned int dimension = dim; + static constexpr unsigned int dimension = dim; /** * Dimensionality of the current object represented by this accessor. For @@ -1881,14 +1881,14 @@ public: * For example, if this accessor represents a quad that is part of a two- * dimensional surface in four-dimensional space, then this value is four. */ - static const unsigned int space_dimension = spacedim; + static constexpr unsigned int space_dimension = spacedim; /** * Dimensionality of the object that the thing represented by this accessor * is part of. For example, if this accessor represents a line that is part * of a hexahedron, then this value will be three. */ - static const unsigned int dimension = dim; + static constexpr unsigned int dimension = dim; /** * Dimensionality of the current object represented by this accessor. For @@ -2299,14 +2299,14 @@ public: * For example, if this accessor represents a quad that is part of a two- * dimensional surface in four-dimensional space, then this value is four. */ - static const unsigned int space_dimension = spacedim; + static constexpr unsigned int space_dimension = spacedim; /** * Dimensionality of the object that the thing represented by this accessor * is part of. For example, if this accessor represents a line that is part * of a hexahedron, then this value will be three. */ - static const unsigned int dimension = 1; + static constexpr unsigned int dimension = 1; /** * Dimensionality of the current object represented by this accessor. For diff --git a/include/deal.II/hp/fe_values.h b/include/deal.II/hp/fe_values.h index b6f4b145d0..713af33038 100644 --- a/include/deal.II/hp/fe_values.h +++ b/include/deal.II/hp/fe_values.h @@ -316,9 +316,9 @@ namespace hp : public hp::FEValuesBase> { public: - static const unsigned int dimension = dim; + static constexpr unsigned int dimension = dim; - static const unsigned int space_dimension = spacedim; + static constexpr unsigned int space_dimension = spacedim; /** * Constructor. Initialize this object with the given parameters. diff --git a/include/deal.II/matrix_free/matrix_free.h b/include/deal.II/matrix_free/matrix_free.h index 77d812cae8..5c456917b8 100644 --- a/include/deal.II/matrix_free/matrix_free.h +++ b/include/deal.II/matrix_free/matrix_free.h @@ -128,7 +128,7 @@ public: /** * The dimension set by the template argument `dim`. */ - static const unsigned int dimension = dim; + static constexpr unsigned int dimension = dim; /** * Collects the options for initialization of the MatrixFree class. The diff --git a/include/deal.II/meshworker/integration_info.h b/include/deal.II/meshworker/integration_info.h index b8260d13d3..6bd1be703a 100644 --- a/include/deal.II/meshworker/integration_info.h +++ b/include/deal.II/meshworker/integration_info.h @@ -81,8 +81,8 @@ namespace MeshWorker std::vector>> fevalv; public: - static const unsigned int dimension = dim; - static const unsigned int space_dimension = spacedim; + static constexpr unsigned int dimension = dim; + static constexpr unsigned int space_dimension = spacedim; /** * Constructor. -- 2.39.5