From 6f306bd2c7bdf301a9e729cf68ccdc22acfa2d78 Mon Sep 17 00:00:00 2001 From: Justin Angus Date: Tue, 27 Aug 2024 10:48:52 -0700 Subject: [PATCH] using std::any_of() --- Source/FieldSolver/Fields.H | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/FieldSolver/Fields.H b/Source/FieldSolver/Fields.H index a3dc10358a3..3c6c2aa3e28 100644 --- a/Source/FieldSolver/Fields.H +++ b/Source/FieldSolver/Fields.H @@ -7,6 +7,8 @@ #ifndef WARPX_FIELDS_H_ #define WARPX_FIELDS_H_ +#include + namespace warpx::fields { enum struct FieldType : int @@ -45,13 +47,11 @@ namespace warpx::fields FieldType::Efield_cp, FieldType::Bfield_cp, FieldType::current_cp, FieldType::Efield_avg_fp, FieldType::Bfield_avg_fp, FieldType::Efield_avg_cp, FieldType::Bfield_avg_cp}; - constexpr bool + inline bool isFieldArray (const FieldType field_type) { - for (const auto& f : ArrayFieldTypes) { - if (f == field_type) { return true; } - } - return false; + return std::any_of( std::begin(ArrayFieldTypes), std::end(ArrayFieldTypes), + [field_type](const FieldType& f) { return f == field_type; }); } }