Skip to content

Commit

Permalink
Merge pull request #15682 from bangerth/array
Browse files Browse the repository at this point in the history
Replace use of C-style array by std::array.
  • Loading branch information
peterrum committed Jul 8, 2023
2 parents ec6a1a9 + dbf05ce commit c75ea6c
Showing 1 changed file with 10 additions and 28 deletions.
38 changes: 10 additions & 28 deletions include/deal.II/numerics/vector_tools_constraints.templates.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace VectorTools
template <int dim>
struct VectorDoFTuple
{
types::global_dof_index dof_indices[dim];
std::array<types::global_dof_index, dim> dof_indices;

VectorDoFTuple()
{
Expand All @@ -50,28 +50,19 @@ namespace VectorTools
bool
operator<(const VectorDoFTuple<dim> &other) const
{
for (unsigned int i = 0; i < dim; ++i)
if (dof_indices[i] < other.dof_indices[i])
return true;
else if (dof_indices[i] > other.dof_indices[i])
return false;
return false;
return (dof_indices < other.dof_indices);
}

bool
operator==(const VectorDoFTuple<dim> &other) const
{
for (unsigned int i = 0; i < dim; ++i)
if (dof_indices[i] != other.dof_indices[i])
return false;

return true;
return (dof_indices == other.dof_indices);
}

bool
operator!=(const VectorDoFTuple<dim> &other) const
{
return !(*this == other);
return (dof_indices != other.dof_indices);
}
};

Expand All @@ -95,33 +86,24 @@ namespace VectorTools
{
static const unsigned int size = 3;
// store active fe indeX, face number, DoF index
unsigned int indices[size];
std::array<unsigned int, size> indices;

bool
operator<(const FaceDoFInfo &other) const
{
for (unsigned int i = 0; i < size; ++i)
if (indices[i] < other.indices[i])
return true;
else if (indices[i] > other.indices[i])
return false;
return false;
return (indices < other.indices);
}

bool
operator==(const FaceDoFInfo &other) const
{
for (unsigned int i = 0; i < size; ++i)
if (indices[i] != other.indices[i])
return false;

return true;
return (indices == other.indices);
}

bool
operator!=(const FaceDoFInfo &other) const
{
return !(*this == other);
return (indices != other.indices);
}
};

Expand Down Expand Up @@ -557,7 +539,7 @@ namespace VectorTools
{
local_vector_indices[0] = i;
const FaceDoFInfo local_face_dof_info = {
{cell->active_fe_index(), face_no, i}};
{{cell->active_fe_index(), face_no, i}}};
for (unsigned int k = 0; k < fe.n_dofs_per_face(face_no);
++k)
if ((k != i) &&
Expand Down Expand Up @@ -657,7 +639,7 @@ namespace VectorTools
!refinement_edge_indices.is_element(face_dofs[i]))
{
const FaceDoFInfo face_dof_info = {
{cell->active_fe_index(), face_no, i}};
{{cell->active_fe_index(), face_no, i}}};
const auto it = dof_to_vector_dof.find(face_dof_info);
Assert(it != dof_to_vector_dof.end(), ExcInternalError());
const std::array<unsigned int, dim> local_vector_indices =
Expand Down

0 comments on commit c75ea6c

Please sign in to comment.