From 53225b735d515e43431992109faaa5e076b6baf6 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 5 Feb 2021 17:13:34 -0700 Subject: [PATCH] Make a function 'constexpr'. I will need this for a later patch where I make the special ReferenceCell objects 'constexpr' as well. This patch is simply meant to make that later review marginally easier. --- include/deal.II/grid/reference_cell.h | 22 ++++++++++++++++++++-- source/grid/reference_cell.cc | 19 ------------------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/include/deal.II/grid/reference_cell.h b/include/deal.II/grid/reference_cell.h index 8c4e11689d..1a466465f6 100644 --- a/include/deal.II/grid/reference_cell.h +++ b/include/deal.II/grid/reference_cell.h @@ -60,7 +60,7 @@ namespace internal * but we have this one function in an internal namespace that is a friend * of the class and can be used to create the objects. */ - dealii::ReferenceCell + constexpr dealii::ReferenceCell make_reference_cell_from_int(const std::uint8_t kind); } // namespace ReferenceCell } // namespace internal @@ -297,7 +297,7 @@ private: * A kind of constructor -- not quite private because it can be * called by anyone, but at least hidden in an internal namespace. */ - friend ReferenceCell + friend constexpr ReferenceCell internal::ReferenceCell::make_reference_cell_from_int(const std::uint8_t); }; @@ -338,6 +338,24 @@ ReferenceCell::operator!=(const ReferenceCell &type) const +namespace internal +{ + namespace ReferenceCell + { + constexpr dealii::ReferenceCell + make_reference_cell_from_int(const std::uint8_t kind) + { + // Make sure these are the only indices from which objects can be + // created. + Assert((kind == static_cast(-1)) || (kind < 8), + ExcInternalError()); + + // Call the private constructor, which we can from here because this + // function is a 'friend'. + return {kind}; + } + } // namespace ReferenceCell +} // namespace internal template inline void ReferenceCell::serialize(Archive &archive, const unsigned int /*version*/) diff --git a/source/grid/reference_cell.cc b/source/grid/reference_cell.cc index c96a8fcb87..aa0f62fc32 100644 --- a/source/grid/reference_cell.cc +++ b/source/grid/reference_cell.cc @@ -31,25 +31,6 @@ DEAL_II_NAMESPACE_OPEN -namespace internal -{ - namespace ReferenceCell - { - dealii::ReferenceCell - make_reference_cell_from_int(const std::uint8_t kind) - { - // Make sure these are the only indices from which objects can be - // created. - Assert((kind == static_cast(-1)) || (kind < 8), - ExcInternalError()); - - // Call the private constructor, which we can from here because this - // function is a 'friend'. - return {kind}; - } - } // namespace ReferenceCell -} // namespace internal - const ReferenceCell ReferenceCell::Vertex = internal::ReferenceCell::make_reference_cell_from_int(0); -- 2.39.5