From: Wolfgang Bangerth Date: Sat, 6 Feb 2021 00:13:34 +0000 (-0700) Subject: Make a function 'constexpr'. X-Git-Tag: v9.3.0-rc1~495^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=53225b735d515e43431992109faaa5e076b6baf6;p=dealii.git 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. --- 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);