Skip to content

Commit

Permalink
Fix unnecessary use of inline constexpr (#1568)
Browse files Browse the repository at this point in the history
  • Loading branch information
sethrj authored Jan 8, 2025
1 parent b3d2514 commit 8f63985
Show file tree
Hide file tree
Showing 18 changed files with 33 additions and 38 deletions.
8 changes: 4 additions & 4 deletions src/accel/SetupOptionsMessenger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ struct UICommandTraits;
template<>
struct UICommandTraits<std::string>
{
static inline constexpr char type_info = 's';
static constexpr char type_info = 's';
static std::string const& to_string(G4String const& v) { return v; }
static std::string from_string(G4String const& v) { return v; }
};

template<>
struct UICommandTraits<bool>
{
static inline constexpr char type_info = 'b';
static constexpr char type_info = 'b';
static G4String to_string(bool v)
{
return G4UIcommand::ConvertToString(v);
Expand All @@ -50,7 +50,7 @@ struct UICommandTraits<bool>
template<class T>
struct UICommandTraits<T, std::enable_if_t<std::is_integral_v<T>>>
{
static inline constexpr char type_info = 'i';
static constexpr char type_info = 'i';
static std::string to_string(T v) { return std::to_string(v); }
static long from_string(G4String const& v)
{
Expand All @@ -69,7 +69,7 @@ struct UICommandTraits<T, std::enable_if_t<std::is_integral_v<T>>>
template<>
struct UICommandTraits<double>
{
static inline constexpr char type_info = 'd';
static constexpr char type_info = 'd';
static G4String to_string(double v)
{
return G4UIcommand::ConvertToString(v);
Expand Down
6 changes: 3 additions & 3 deletions src/celeritas/field/FieldDriverOptions.hh
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ struct FieldDriverOptions
short int max_substeps = 10;

//! Initial step tolerance
static constexpr inline real_type initial_step_tol = 1e-6;
static constexpr real_type initial_step_tol = 1e-6;

//! Chord distance fudge factor
static constexpr inline real_type dchord_tol = 1e-5 * units::millimeter;
static constexpr real_type dchord_tol = 1e-5 * units::millimeter;

//! Lowest allowable scaling factor when searching for a chord
static constexpr inline real_type min_chord_shrink = 0.5;
static constexpr real_type min_chord_shrink = 0.5;

//! Whether all data are assigned and valid
explicit CELER_FUNCTION operator bool() const
Expand Down
4 changes: 1 addition & 3 deletions src/celeritas/io/ImportMaterial.hh
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ struct ImportPhysMaterial
using MapIntCutoff = std::map<PdgInt, ImportProductionCut>;
//!@}

#ifndef SWIG
static inline constexpr Index unspecified = -1;
#endif
static constexpr Index unspecified = -1;

Index geo_material_id{}; //!< Index in geo_materials list
Index optical_material_id{unspecified}; //!< Optional index in optical mat
Expand Down
4 changes: 1 addition & 3 deletions src/celeritas/io/ImportVolume.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ struct ImportVolume
using Index = unsigned int;
//!@}

#ifndef SWIG
static inline constexpr Index unspecified = -1;
#endif
static constexpr Index unspecified = -1;

Index geo_material_id{unspecified}; //!< Material defined by geometry
Index region_id{unspecified}; //!< Optional region associated
Expand Down
3 changes: 1 addition & 2 deletions src/celeritas/track/StatusCheckData.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ struct StatusCheckParamsData

celeritas::Collection<StepActionOrder, W, M, ActionId> orders;

static inline constexpr StepActionOrder implicit_order
= StepActionOrder::size_;
static constexpr StepActionOrder implicit_order = StepActionOrder::size_;

//// METHODS ////

Expand Down
4 changes: 2 additions & 2 deletions src/celeritas/user/RootStepWriter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class RootFileManager;
//! Input to \c make_write_filter (below) for filtering ROOT MC truth output
struct SimpleRootFilterInput
{
static inline constexpr size_type unspecified{static_cast<size_type>(-1)};
static constexpr size_type unspecified{static_cast<size_type>(-1)};

std::vector<size_type> track_id;
size_type event_id = unspecified;
Expand Down Expand Up @@ -58,7 +58,7 @@ class RootStepWriter final : public StepInterface
{
public:
// Unspecified step attribute data value
static inline constexpr size_type unspecified{static_cast<size_type>(-1)};
static constexpr size_type unspecified{static_cast<size_type>(-1)};

//! Truth step point data; Naming convention must match StepPointStateData
struct TStepPoint
Expand Down
2 changes: 1 addition & 1 deletion src/corecel/cont/InitializedValue.hh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ template<class T, class Finalizer = detail::DefaultFinalize<T>>
class InitializedValue
{
private:
static inline constexpr bool ne_finalize_
static constexpr bool ne_finalize_
= noexcept(std::declval<Finalizer>()(std::declval<T&>()));

public:
Expand Down
4 changes: 2 additions & 2 deletions src/corecel/data/Collection.hh
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ class Collection
using AllItemsT = AllItems<T, M>;
//!@}

static constexpr inline Ownership ownership = W;
static constexpr inline MemSpace memspace = M;
static constexpr Ownership ownership = W;
static constexpr MemSpace memspace = M;

public:
//// CONSTRUCTION ////
Expand Down
2 changes: 1 addition & 1 deletion src/corecel/math/BisectionRootFinder.hh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class BisectionRootFinder
real_type tol_;

// Maximum amount of iterations
static constexpr inline int max_iters_ = 50;
static constexpr int max_iters_ = 50;
};

//---------------------------------------------------------------------------//
Expand Down
2 changes: 1 addition & 1 deletion src/corecel/math/IllinoisRootFinder.hh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class IllinoisRootFinder
real_type tol_;

// Maximum amount of iterations
static constexpr inline int max_iters_ = 50;
static constexpr int max_iters_ = 50;
};

//---------------------------------------------------------------------------//
Expand Down
2 changes: 1 addition & 1 deletion src/corecel/math/RegulaFalsiRootFinder.hh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class RegulaFalsiRootFinder
real_type tol_;

// Maximum amount of iterations
static constexpr inline int max_iters_ = 50;
static constexpr int max_iters_ = 50;
};

//---------------------------------------------------------------------------//
Expand Down
2 changes: 1 addition & 1 deletion src/corecel/sys/TracingSession.hh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class TracingSession
CELER_DELETE_COPY_MOVE(TracingSession);

private:
static inline constexpr int system_fd_{-1};
static constexpr int system_fd_{-1};
struct Deleter
{
void operator()(perfetto::TracingSession*);
Expand Down
8 changes: 4 additions & 4 deletions src/geocel/GeoTraits.hh
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ struct GeoTraits
using TrackView = void;

//! Descriptive name for the geometry
static constexpr inline char const* name = nullptr;
static constexpr char const* name = nullptr;

//! TO BE REMOVED: "native" file extension for this geometry
static constexpr inline char const* ext = nullptr;
static constexpr char const* ext = nullptr;
};

//---------------------------------------------------------------------------//
Expand All @@ -68,8 +68,8 @@ struct NotConfiguredGeoTraits
template<Ownership W, MemSpace M>
using StateData = void;
using TrackView = void;
static constexpr inline char const* name = nullptr;
static constexpr inline char const* ext = nullptr;
static constexpr char const* name = nullptr;
static constexpr char const* ext = nullptr;
};

//---------------------------------------------------------------------------//
Expand Down
4 changes: 2 additions & 2 deletions src/geocel/g4/GeantGeoTraits.hh
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ struct GeoTraits<GeantGeoParams>
using TrackView = GeantGeoTrackView;

//! Descriptive name for the geometry
static constexpr inline char const* name = "Geant4";
static constexpr char const* name = "Geant4";

//! TO BE REMOVED: "native" file extension for this geometry
static constexpr inline char const* ext = ".gdml";
static constexpr char const* ext = ".gdml";
};
#else
//! Geant4 is unavailable
Expand Down
4 changes: 2 additions & 2 deletions src/geocel/vg/VecgeomGeoTraits.hh
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ struct GeoTraits<VecgeomParams>
using TrackView = VecgeomTrackView;

//! Descriptive name for the geometry
static constexpr inline char const* name = "VecGeom";
static constexpr char const* name = "VecGeom";

//! TO BE REMOVED: "native" file extension for this geometry
static constexpr inline char const* ext = ".gdml";
static constexpr char const* ext = ".gdml";
};
#else
//! VecGeom is unavailable
Expand Down
4 changes: 2 additions & 2 deletions src/orange/OrangeData.hh
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ namespace celeritas
//---------------------------------------------------------------------------//

//! Local ID of exterior volume for unit-type universes
static inline constexpr LocalVolumeId orange_exterior_volume{0};
inline constexpr LocalVolumeId orange_exterior_volume{0};

//! ID of the top-level (global/world, level=0) universe (scene)
static inline constexpr UniverseId orange_global_universe{0};
inline constexpr UniverseId orange_global_universe{0};

//---------------------------------------------------------------------------//
/*!
Expand Down
4 changes: 2 additions & 2 deletions src/orange/OrangeGeoTraits.hh
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ struct GeoTraits<OrangeParams>
using TrackView = OrangeTrackView;

//! Descriptive name for the geometry
static constexpr inline char const* name = "ORANGE";
static constexpr char const* name = "ORANGE";

//! TO BE REMOVED: "native" file extension for this geometry
static constexpr inline char const* ext = ".org.json";
static constexpr char const* ext = ".org.json";
};

//---------------------------------------------------------------------------//
Expand Down
4 changes: 2 additions & 2 deletions test/orange/surf/FaceNamer.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ namespace test
class FaceNamerTest : public ::celeritas::test::Test
{
protected:
static inline constexpr auto in = Sense::inside;
static inline constexpr auto out = Sense::outside;
static constexpr auto in = Sense::inside;
static constexpr auto out = Sense::outside;
};

TEST_F(FaceNamerTest, typed)
Expand Down

0 comments on commit 8f63985

Please sign in to comment.