*/
namespace ReferenceCell
{
+ class Type;
+
+ namespace internal
+ {
+ /**
+ * A helper function to create a ReferenceCell::Type object from an
+ * integer. ReferenceCell::Type objects are "singletons" (actually,
+ * "multitons" -- there are multiple, but they are only a handful and
+ * these are all that can be used). What is then necessary is to
+ * have a way to create these with their internal id to distinguish
+ * the few possible ones in existence. We could do this via a public
+ * constructor of ReferenceCell::Type, but that would allow users to
+ * create ones outside the range we envision, and we don't want to do
+ * that. Rather, the constructor that takes an integer is made `private`
+ * 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.
+ */
+ Type
+ make_reference_cell_from_int(const std::uint8_t kind);
+ } // namespace internal
+
+
+
/**
* A type that describes the kinds of reference cells that can be used.
* This includes quadrilaterals and hexahedra (i.e., "hypercubes"),
*/
constexpr Type();
- /**
- * Constructor.
- */
- constexpr Type(const std::uint8_t kind);
-
-
/**
* Return true if the object is a Vertex, Line, Quad, or Hex.
*/
* The variable that stores what this object actually corresponds to.
*/
std::uint8_t kind;
+
+ /**
+ * Constructor. This is the constructor used to create the different
+ * `static` member variables of this class. It is `private` but can
+ * be called by a function in an internal namespace that is a `friend`
+ * of this class.
+ */
+ constexpr Type(const std::uint8_t kind);
+
+ /**
+ * A kind of constructor -- not quite private because it can be
+ * called by anyone, but at least hidden in an internal namespace.
+ */
+ friend Type
+ internal::make_reference_cell_from_int(const std::uint8_t);
};
// transform back and store result
this->reference_cell_types.clear();
for (const auto &i : reference_cell_types_ui)
- this->reference_cell_types.emplace_back(static_cast<std::uint8_t>(i));
+ this->reference_cell_types.emplace_back(
+ ReferenceCell::internal::make_reference_cell_from_int(i));
}
DEAL_II_NAMESPACE_OPEN
+
namespace ReferenceCell
{
- const Type Type::Vertex = Type(0);
- const Type Type::Line = Type(1);
- const Type Type::Tri = Type(2);
- const Type Type::Quad = Type(3);
- const Type Type::Tet = Type(4);
- const Type Type::Pyramid = Type(5);
- const Type Type::Wedge = Type(6);
- const Type Type::Hex = Type(7);
- const Type Type::Invalid = Type(static_cast<std::uint8_t>(-1));
+ namespace internal
+ {
+ dealii::ReferenceCell::Type
+ make_reference_cell_from_int(const std::uint8_t kind)
+ {
+ // Call the private constructor, which we can from here because this
+ // function is a 'friend'.
+ return dealii::ReferenceCell::Type(kind);
+ }
+ } // namespace internal
+
+
+ const Type Type::Vertex = internal::make_reference_cell_from_int(0);
+ const Type Type::Line = internal::make_reference_cell_from_int(1);
+ const Type Type::Tri = internal::make_reference_cell_from_int(2);
+ const Type Type::Quad = internal::make_reference_cell_from_int(3);
+ const Type Type::Tet = internal::make_reference_cell_from_int(4);
+ const Type Type::Pyramid = internal::make_reference_cell_from_int(5);
+ const Type Type::Wedge = internal::make_reference_cell_from_int(6);
+ const Type Type::Hex = internal::make_reference_cell_from_int(7);
+ const Type Type::Invalid =
+ internal::make_reference_cell_from_int(static_cast<std::uint8_t>(-1));
template <int dim, int spacedim>