Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace use of C-style array by std::array. #15682

Merged
merged 2 commits into from
Jul 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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