From 01e9c15c911f9322f49bb1402b1aee6abb3de454 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <github@naumov.de> Date: Fri, 1 Mar 2019 22:43:14 +0100 Subject: [PATCH] Mark single parameter ctors as explicit. Also those where the second and so forth arguments are defaulted. The MathLib::TemplateVector3 is an exception, because of the many required changes through the code, which relies on the implicit conversion from TemplatePoint<T, 3> to TemplateVector3<T>. clang-tidy '*explicit*' check. --- BaseLib/Histogram.h | 4 ++-- GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.h | 2 +- GeoLib/MinimalBoundingSphere.h | 7 +++++-- GeoLib/Point.h | 6 +++--- GeoLib/Polygon.h | 2 +- GeoLib/Polyline.h | 2 +- GeoLib/SensorData.h | 4 ++-- GeoLib/Station.h | 10 +++++----- GeoLib/StationBorehole.h | 5 ++++- .../CapillaryPressureSaturationCurve.h | 2 +- .../RelativePermeability/RelativePermeabilityCurve.h | 2 +- MathLib/ODE/ConcreteODESolver.h | 2 +- MathLib/Point3dWithID.h | 3 ++- MeshGeoToolsLib/HeuristicSearchLength.h | 4 ++-- MeshLib/Elements/TemplateElement.h | 8 ++++++-- MeshLib/IO/VtkIO/VtuInterface.h | 4 +++- MeshLib/MeshEditing/MeshRevision.h | 2 +- MeshLib/MeshQuality/AngleSkewMetric.h | 2 +- MeshLib/MeshQuality/EdgeRatioMetric.h | 2 +- MeshLib/MeshQuality/ElementQualityMetric.h | 2 +- MeshLib/MeshQuality/ElementSizeMetric.h | 2 +- MeshLib/MeshQuality/MeshValidation.h | 2 +- MeshLib/MeshQuality/RadiusEdgeRatioMetric.h | 2 +- MeshLib/MeshQuality/SizeDifferenceMetric.h | 2 +- MeshLib/Node.h | 6 ++++-- NumLib/Fem/FiniteElement/TemplateIsoparametric.h | 2 +- NumLib/Function/TemplateSpatialFunction.h | 2 +- NumLib/NamedFunctionCaller.h | 2 +- NumLib/ODESolver/ConvergenceCriterion.h | 2 +- NumLib/ODESolver/ConvergenceCriterionPerComponent.h | 3 ++- NumLib/ODESolver/MatrixTranslator.h | 12 +++++------- .../BHEBottomDirichletBoundaryCondition.h | 2 +- .../BoundaryCondition/BoundaryConditionCollection.h | 2 +- ProcessLib/Output/Output.h | 4 +++- ProcessLib/SourceTerms/SourceTermCollection.h | 2 +- Tests/AutoCheckTools.h | 3 ++- Tests/BaseLib/TestFunctional.cpp | 2 +- Tests/GeoLib/AutoCheckGenerators.h | 5 +++-- Tests/MaterialLib/TestMPLParseMaterial.cpp | 4 ++-- Tests/MathLib/TestGaussLegendreIntegration.cpp | 9 ++++++--- Tests/NumLib/TestNamedFunction.cpp | 2 +- 41 files changed, 84 insertions(+), 63 deletions(-) diff --git a/BaseLib/Histogram.h b/BaseLib/Histogram.h index 4a6159f1495..9a7bdea1704 100644 --- a/BaseLib/Histogram.h +++ b/BaseLib/Histogram.h @@ -61,8 +61,8 @@ public: * \param computeHistogram Compute histogram if set. If not set user must call * \c update() before accessing data. */ - Histogram(std::vector<T> data, const unsigned int nr_bins = 16, - const bool computeHistogram = true) + explicit Histogram(std::vector<T> data, const unsigned int nr_bins = 16, + const bool computeHistogram = true) : _data(std::move(data)), _nr_bins(nr_bins) { init(computeHistogram); diff --git a/GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.h b/GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.h index b02b118cc2e..775e51ec8fb 100644 --- a/GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.h +++ b/GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.h @@ -35,7 +35,7 @@ namespace IO class BoostXmlGmlInterface : public BaseLib::IO::XMLInterface { public: - BoostXmlGmlInterface(GeoLib::GEOObjects& geo_objs); + explicit BoostXmlGmlInterface(GeoLib::GEOObjects& geo_objs); ~BoostXmlGmlInterface() override = default; /// Reads an xml-file containing OGS geometry diff --git a/GeoLib/MinimalBoundingSphere.h b/GeoLib/MinimalBoundingSphere.h index adb9b6e5836..2973dd5a5fb 100644 --- a/GeoLib/MinimalBoundingSphere.h +++ b/GeoLib/MinimalBoundingSphere.h @@ -30,7 +30,9 @@ class MinimalBoundingSphere { public: /// Point-Sphere - MinimalBoundingSphere(MathLib::Point3d const& p, double radius = std::numeric_limits<double>::epsilon()); + explicit MinimalBoundingSphere( + MathLib::Point3d const& p, + double radius = std::numeric_limits<double>::epsilon()); /// Bounding sphere using two points MinimalBoundingSphere(MathLib::Point3d const& p, MathLib::Point3d const& q); /// Bounding sphere using three points @@ -42,7 +44,8 @@ public: MathLib::Point3d const& r, MathLib::Point3d const& s); /// Bounding sphere of n points - MinimalBoundingSphere(std::vector<MathLib::Point3d*> const& points); + explicit MinimalBoundingSphere( + std::vector<MathLib::Point3d*> const& points); /// Returns the center point of the sphere MathLib::Point3d getCenter() const { return MathLib::Point3d(_center); } diff --git a/GeoLib/Point.h b/GeoLib/Point.h index f8af4d5f3ad..4e0160ac77f 100644 --- a/GeoLib/Point.h +++ b/GeoLib/Point.h @@ -46,9 +46,9 @@ public: MathLib::Point3dWithID(x, id), GeoLib::GeoObject() {} - Point(std::array<double,3> const& x, - std::size_t id = std::numeric_limits<std::size_t>::max()) : - MathLib::Point3dWithID(x, id), GeoLib::GeoObject() + explicit Point(std::array<double, 3> const& x, + std::size_t id = std::numeric_limits<std::size_t>::max()) + : MathLib::Point3dWithID(x, id), GeoLib::GeoObject() {} /// return a geometry type diff --git a/GeoLib/Polygon.h b/GeoLib/Polygon.h index 9729480fb8d..930ec7b9008 100644 --- a/GeoLib/Polygon.h +++ b/GeoLib/Polygon.h @@ -49,7 +49,7 @@ public: * @param ply closed Polyline * @param init if true, check if polyline is closed, calculate bounding box */ - Polygon(const Polyline &ply, bool init = true); + explicit Polygon(const Polyline& ply, bool init = true); Polygon(Polygon const& other); Polygon& operator=(Polygon const& rhs) = delete; diff --git a/GeoLib/Polyline.h b/GeoLib/Polyline.h index a37a258a615..8373e14fc0c 100644 --- a/GeoLib/Polyline.h +++ b/GeoLib/Polyline.h @@ -93,7 +93,7 @@ public: /** constructor * \param pnt_vec a reference to the point vector */ - Polyline(const std::vector<Point*>& pnt_vec); + explicit Polyline(const std::vector<Point*>& pnt_vec); /** * Copy constructor * @param ply Polyline diff --git a/GeoLib/SensorData.h b/GeoLib/SensorData.h index 4c4bec67999..0ca95fa8c0b 100644 --- a/GeoLib/SensorData.h +++ b/GeoLib/SensorData.h @@ -62,10 +62,10 @@ class SensorData { public: /// Constructor using file name (automatically reads the file and fills all data structures) - SensorData(const std::string &file_name); + explicit SensorData(const std::string& file_name); /// Constructor using a time step vector valid for all time series that will be added later - SensorData(std::vector<std::size_t> time_steps); + explicit SensorData(std::vector<std::size_t> time_steps); /// Constructor using time step bounds for all time series that will be added later SensorData(std::size_t first_timestep, std::size_t last_timestep, std::size_t step_size); diff --git a/GeoLib/Station.h b/GeoLib/Station.h index 1f50b59723e..0e0eca668d5 100644 --- a/GeoLib/Station.h +++ b/GeoLib/Station.h @@ -52,12 +52,12 @@ public: * \param z The z-coordinate of the station. * \param name The name of the station. */ - Station(double x = 0.0, - double y = 0.0, - double z = 0.0, - std::string name = ""); + explicit Station(double x = 0.0, + double y = 0.0, + double z = 0.0, + std::string name = ""); - Station(Point* coords, std::string name = ""); + explicit Station(Point* coords, std::string name = ""); /** * Constructor copies the source object diff --git a/GeoLib/StationBorehole.h b/GeoLib/StationBorehole.h index e8861b01f6c..506acbbe59e 100644 --- a/GeoLib/StationBorehole.h +++ b/GeoLib/StationBorehole.h @@ -32,7 +32,10 @@ class StationBorehole : public Station { public: /** constructor initialises the borehole with the given coordinates */ - StationBorehole(double x = 0.0, double y = 0.0, double z = 0.0, const std::string &name = ""); + explicit StationBorehole(double x = 0.0, + double y = 0.0, + double z = 0.0, + const std::string& name = ""); ~StationBorehole(void) override; /// Creates a StationBorehole-object from a string (assuming the string has the right format) diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CapillaryPressureSaturationCurve.h b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CapillaryPressureSaturationCurve.h index 7362a2b4e42..88f7e9455ab 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CapillaryPressureSaturationCurve.h +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CapillaryPressureSaturationCurve.h @@ -27,7 +27,7 @@ class CapillaryPressureSaturationCurve final : public CapillaryPressureSaturation { public: - CapillaryPressureSaturationCurve( + explicit CapillaryPressureSaturationCurve( std::unique_ptr<MathLib::PiecewiseLinearMonotonicCurve>&& curve_data) : CapillaryPressureSaturation( curve_data->getSupportMin(), diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/RelativePermeabilityCurve.h b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/RelativePermeabilityCurve.h index d4676428ef4..7edb0e8017e 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/RelativePermeabilityCurve.h +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/RelativePermeabilityCurve.h @@ -25,7 +25,7 @@ namespace PorousMedium class RelativePermeabilityCurve final : public RelativePermeability { public: - RelativePermeabilityCurve( + explicit RelativePermeabilityCurve( std::unique_ptr<MathLib::PiecewiseLinearInterpolation>&& curve_data) : RelativePermeability(curve_data->getSupportMin(), curve_data->getSupportMax()), diff --git a/MathLib/ODE/ConcreteODESolver.h b/MathLib/ODE/ConcreteODESolver.h index 09ddd4935c7..29db9127fee 100644 --- a/MathLib/ODE/ConcreteODESolver.h +++ b/MathLib/ODE/ConcreteODESolver.h @@ -104,7 +104,7 @@ public: private: //! Instances of this class shall only be constructed by createODESolver(). - ConcreteODESolver(BaseLib::ConfigTree const& config) + explicit ConcreteODESolver(BaseLib::ConfigTree const& config) : Implementation{config, NumEquations} { } diff --git a/MathLib/Point3dWithID.h b/MathLib/Point3dWithID.h index 87f8fe8a99e..cca3e48c0a7 100644 --- a/MathLib/Point3dWithID.h +++ b/MathLib/Point3dWithID.h @@ -40,7 +40,8 @@ public: /// the provided id. /// @param coords coordinates of the point /// @param id the id of the object [default: max of std::size_t] - Point3dWithID(std::array<double,3> const& coords, + explicit Point3dWithID( + std::array<double, 3> const& coords, std::size_t id = std::numeric_limits<std::size_t>::max()) : Point3d(coords), _id(id) {} diff --git a/MeshGeoToolsLib/HeuristicSearchLength.h b/MeshGeoToolsLib/HeuristicSearchLength.h index 34af6a5ca07..d16dc653a98 100644 --- a/MeshGeoToolsLib/HeuristicSearchLength.h +++ b/MeshGeoToolsLib/HeuristicSearchLength.h @@ -41,8 +41,8 @@ public: * @param mesh mesh object * @param length_type length type to be sampled */ - HeuristicSearchLength(MeshLib::Mesh const& mesh, - LengthType length_type = LengthType::Edge); + explicit HeuristicSearchLength(MeshLib::Mesh const& mesh, + LengthType length_type = LengthType::Edge); private: MeshLib::Mesh const& _mesh; diff --git a/MeshLib/Elements/TemplateElement.h b/MeshLib/Elements/TemplateElement.h index ef7d53d33f8..3505a95e151 100644 --- a/MeshLib/Elements/TemplateElement.h +++ b/MeshLib/Elements/TemplateElement.h @@ -46,7 +46,9 @@ public: * @param nodes an array of pointers of mesh nodes which form this element * @param id element id */ - TemplateElement(Node* nodes[n_all_nodes], std::size_t id = std::numeric_limits<std::size_t>::max()); + explicit TemplateElement( + Node* nodes[n_all_nodes], + std::size_t id = std::numeric_limits<std::size_t>::max()); /** * Constructor with an array of mesh nodes @@ -54,7 +56,9 @@ public: * @param nodes an array of pointers of mesh nodes which form this element * @param id element id */ - TemplateElement(std::array<Node*, n_all_nodes> const& nodes, std::size_t id = std::numeric_limits<std::size_t>::max()); + explicit TemplateElement( + std::array<Node*, n_all_nodes> const& nodes, + std::size_t id = std::numeric_limits<std::size_t>::max()); /// Copy constructor TemplateElement(const TemplateElement &e); diff --git a/MeshLib/IO/VtkIO/VtuInterface.h b/MeshLib/IO/VtkIO/VtuInterface.h index cc3c6debdc0..c21776ee1e3 100644 --- a/MeshLib/IO/VtkIO/VtuInterface.h +++ b/MeshLib/IO/VtkIO/VtuInterface.h @@ -37,7 +37,9 @@ class VtuInterface final { public: /// Provide the mesh to write and set if compression should be used. - VtuInterface(const MeshLib::Mesh* mesh, int dataMode = vtkXMLWriter::Binary, bool compressed = false); + explicit VtuInterface(const MeshLib::Mesh* mesh, + int dataMode = vtkXMLWriter::Binary, + bool compressed = false); /// Read an unstructured grid from a VTU file /// \return The converted mesh or a nullptr if reading failed diff --git a/MeshLib/MeshEditing/MeshRevision.h b/MeshLib/MeshEditing/MeshRevision.h index adcaa308d65..e2d6267399d 100644 --- a/MeshLib/MeshEditing/MeshRevision.h +++ b/MeshLib/MeshEditing/MeshRevision.h @@ -39,7 +39,7 @@ public: * Constructor * @param mesh The mesh which is being revised. Note that node IDs in mesh are changed during computation but are resetted after the algorithms implemented here are finished */ - MeshRevision(MeshLib::Mesh &mesh); + explicit MeshRevision(MeshLib::Mesh& mesh); virtual ~MeshRevision() = default; diff --git a/MeshLib/MeshQuality/AngleSkewMetric.h b/MeshLib/MeshQuality/AngleSkewMetric.h index cbf721f3f39..4fe5b43d7f1 100644 --- a/MeshLib/MeshQuality/AngleSkewMetric.h +++ b/MeshLib/MeshQuality/AngleSkewMetric.h @@ -25,7 +25,7 @@ namespace MeshLib class AngleSkewMetric final : public ElementQualityMetric { public: - AngleSkewMetric(Mesh const& mesh); + explicit AngleSkewMetric(Mesh const& mesh); void calculateQuality() override; diff --git a/MeshLib/MeshQuality/EdgeRatioMetric.h b/MeshLib/MeshQuality/EdgeRatioMetric.h index 6ef677f5a88..84dbfb08ed4 100644 --- a/MeshLib/MeshQuality/EdgeRatioMetric.h +++ b/MeshLib/MeshQuality/EdgeRatioMetric.h @@ -26,7 +26,7 @@ namespace MeshLib class EdgeRatioMetric : public ElementQualityMetric { public: - EdgeRatioMetric(Mesh const& mesh); + explicit EdgeRatioMetric(Mesh const& mesh); ~EdgeRatioMetric() override = default; void calculateQuality() override; diff --git a/MeshLib/MeshQuality/ElementQualityMetric.h b/MeshLib/MeshQuality/ElementQualityMetric.h index 88d62720291..de83ac683d8 100644 --- a/MeshLib/MeshQuality/ElementQualityMetric.h +++ b/MeshLib/MeshQuality/ElementQualityMetric.h @@ -32,7 +32,7 @@ namespace MeshLib class ElementQualityMetric { public: - ElementQualityMetric(Mesh const& mesh); + explicit ElementQualityMetric(Mesh const& mesh); virtual ~ElementQualityMetric() = default; diff --git a/MeshLib/MeshQuality/ElementSizeMetric.h b/MeshLib/MeshQuality/ElementSizeMetric.h index 87730d76ad3..2277f41d12b 100644 --- a/MeshLib/MeshQuality/ElementSizeMetric.h +++ b/MeshLib/MeshQuality/ElementSizeMetric.h @@ -25,7 +25,7 @@ namespace MeshLib class ElementSizeMetric : public ElementQualityMetric { public: - ElementSizeMetric(Mesh const& mesh); + explicit ElementSizeMetric(Mesh const& mesh); ~ElementSizeMetric() override = default; void calculateQuality() override; diff --git a/MeshLib/MeshQuality/MeshValidation.h b/MeshLib/MeshQuality/MeshValidation.h index ce7ccea4c3c..9a0717d7fda 100644 --- a/MeshLib/MeshQuality/MeshValidation.h +++ b/MeshLib/MeshQuality/MeshValidation.h @@ -32,7 +32,7 @@ class MeshValidation public: /// Constructor /// \warning This might change the mesh when removing unused mesh nodes. - MeshValidation(MeshLib::Mesh &mesh); + explicit MeshValidation(MeshLib::Mesh& mesh); ~MeshValidation() = default; /** diff --git a/MeshLib/MeshQuality/RadiusEdgeRatioMetric.h b/MeshLib/MeshQuality/RadiusEdgeRatioMetric.h index 67a96afb401..8a91a84273b 100644 --- a/MeshLib/MeshQuality/RadiusEdgeRatioMetric.h +++ b/MeshLib/MeshQuality/RadiusEdgeRatioMetric.h @@ -26,7 +26,7 @@ namespace MeshLib class RadiusEdgeRatioMetric : public ElementQualityMetric { public: - RadiusEdgeRatioMetric(Mesh const& mesh); + explicit RadiusEdgeRatioMetric(Mesh const& mesh); ~RadiusEdgeRatioMetric() override = default; void calculateQuality() override; diff --git a/MeshLib/MeshQuality/SizeDifferenceMetric.h b/MeshLib/MeshQuality/SizeDifferenceMetric.h index f05754b9bb9..f6af7c9a7b5 100644 --- a/MeshLib/MeshQuality/SizeDifferenceMetric.h +++ b/MeshLib/MeshQuality/SizeDifferenceMetric.h @@ -26,7 +26,7 @@ namespace MeshLib class SizeDifferenceMetric : public ElementQualityMetric { public: - SizeDifferenceMetric(Mesh const& mesh); + explicit SizeDifferenceMetric(Mesh const& mesh); ~SizeDifferenceMetric() override = default; void calculateQuality() override; diff --git a/MeshLib/Node.h b/MeshLib/Node.h index e3470fff3f2..657aba03a80 100644 --- a/MeshLib/Node.h +++ b/MeshLib/Node.h @@ -44,10 +44,12 @@ class Node : public MathLib::Point3dWithID public: /// Constructor using a coordinate array - Node(const double coords[3], std::size_t id = std::numeric_limits<std::size_t>::max()); + explicit Node(const double coords[3], + std::size_t id = std::numeric_limits<std::size_t>::max()); /// Constructor using a coordinate array - Node(std::array<double, 3> const& coords, std::size_t id = std::numeric_limits<std::size_t>::max()); + explicit Node(std::array<double, 3> const& coords, + std::size_t id = std::numeric_limits<std::size_t>::max()); /// Constructor using single coordinates Node(double x, double y, double z, std::size_t id = std::numeric_limits<std::size_t>::max()); diff --git a/NumLib/Fem/FiniteElement/TemplateIsoparametric.h b/NumLib/Fem/FiniteElement/TemplateIsoparametric.h index 9a09121fc05..cdbe4fd08a5 100644 --- a/NumLib/Fem/FiniteElement/TemplateIsoparametric.h +++ b/NumLib/Fem/FiniteElement/TemplateIsoparametric.h @@ -55,7 +55,7 @@ public: * * @param e Mesh element object */ - TemplateIsoparametric(const MeshElementType& e) : _ele(&e) {} + explicit TemplateIsoparametric(const MeshElementType& e) : _ele(&e) {} ~TemplateIsoparametric() = default; /// return current mesh element diff --git a/NumLib/Function/TemplateSpatialFunction.h b/NumLib/Function/TemplateSpatialFunction.h index f645ace89e3..6535669311b 100644 --- a/NumLib/Function/TemplateSpatialFunction.h +++ b/NumLib/Function/TemplateSpatialFunction.h @@ -32,7 +32,7 @@ public: * Constructor * @param f a function object */ - TemplateSpatialFunction(T_FUNCTION f) : _f(std::move(f)) {} + explicit TemplateSpatialFunction(T_FUNCTION f) : _f(std::move(f)) {} /** * evaluate a function * @param pnt a point object diff --git a/NumLib/NamedFunctionCaller.h b/NumLib/NamedFunctionCaller.h index 365b1907a37..6c98637c2bf 100644 --- a/NumLib/NamedFunctionCaller.h +++ b/NumLib/NamedFunctionCaller.h @@ -22,7 +22,7 @@ class NamedFunctionCaller final { public: //! Constructs an instance whose unbound arguments have the given names. - explicit NamedFunctionCaller( + NamedFunctionCaller( std::initializer_list<std::string> unbound_argument_names); //! Adds the given named function diff --git a/NumLib/ODESolver/ConvergenceCriterion.h b/NumLib/ODESolver/ConvergenceCriterion.h index a60f0a2f446..2f139d7ddf5 100644 --- a/NumLib/ODESolver/ConvergenceCriterion.h +++ b/NumLib/ODESolver/ConvergenceCriterion.h @@ -28,7 +28,7 @@ namespace NumLib class ConvergenceCriterion { public: - ConvergenceCriterion(const MathLib::VecNormType norm_type) + explicit ConvergenceCriterion(const MathLib::VecNormType norm_type) : _norm_type(norm_type) { } diff --git a/NumLib/ODESolver/ConvergenceCriterionPerComponent.h b/NumLib/ODESolver/ConvergenceCriterionPerComponent.h index 59f2bfb681a..6bc194c42c4 100644 --- a/NumLib/ODESolver/ConvergenceCriterionPerComponent.h +++ b/NumLib/ODESolver/ConvergenceCriterionPerComponent.h @@ -28,7 +28,8 @@ class LocalToGlobalIndexMap; class ConvergenceCriterionPerComponent : public ConvergenceCriterion { public: - ConvergenceCriterionPerComponent(const MathLib::VecNormType norm_type) + explicit ConvergenceCriterionPerComponent( + const MathLib::VecNormType norm_type) : ConvergenceCriterion(norm_type) { } diff --git a/NumLib/ODESolver/MatrixTranslator.h b/NumLib/ODESolver/MatrixTranslator.h index b82b508e5a6..9e30705e864 100644 --- a/NumLib/ODESolver/MatrixTranslator.h +++ b/NumLib/ODESolver/MatrixTranslator.h @@ -102,7 +102,7 @@ public: * * \param timeDisc the time discretization scheme to be used. */ - MatrixTranslatorGeneral(TimeDiscretization const& timeDisc) + explicit MatrixTranslatorGeneral(TimeDiscretization const& timeDisc) : _time_disc(timeDisc) { } @@ -159,7 +159,7 @@ public: * * \param timeDisc the time discretization scheme to be used. */ - MatrixTranslatorForwardEuler(ForwardEuler const& timeDisc) + explicit MatrixTranslatorForwardEuler(ForwardEuler const& timeDisc) : _fwd_euler(timeDisc) { } @@ -215,12 +215,10 @@ public: * * \param timeDisc the time discretization scheme to be used. */ - MatrixTranslatorCrankNicolson(CrankNicolson const& timeDisc) + explicit MatrixTranslatorCrankNicolson(CrankNicolson const& timeDisc) : _crank_nicolson(timeDisc), - _M_bar(NumLib::GlobalMatrixProvider::provider - .getMatrix()), - _b_bar( - NumLib::GlobalVectorProvider::provider.getVector()) + _M_bar(NumLib::GlobalMatrixProvider::provider.getMatrix()), + _b_bar(NumLib::GlobalVectorProvider::provider.getVector()) { } diff --git a/ProcessLib/BoundaryCondition/BHEBottomDirichletBoundaryCondition.h b/ProcessLib/BoundaryCondition/BHEBottomDirichletBoundaryCondition.h index 705d7852747..73c8edde3a5 100644 --- a/ProcessLib/BoundaryCondition/BHEBottomDirichletBoundaryCondition.h +++ b/ProcessLib/BoundaryCondition/BHEBottomDirichletBoundaryCondition.h @@ -17,7 +17,7 @@ namespace ProcessLib class BHEBottomDirichletBoundaryCondition final : public BoundaryCondition { public: - BHEBottomDirichletBoundaryCondition( + explicit BHEBottomDirichletBoundaryCondition( std::pair<GlobalIndexType, GlobalIndexType>&& in_out_global_indices) : _in_out_global_indices(std::move(in_out_global_indices)) { diff --git a/ProcessLib/BoundaryCondition/BoundaryConditionCollection.h b/ProcessLib/BoundaryCondition/BoundaryConditionCollection.h index d957ef0e18d..b6bebef421b 100644 --- a/ProcessLib/BoundaryCondition/BoundaryConditionCollection.h +++ b/ProcessLib/BoundaryCondition/BoundaryConditionCollection.h @@ -19,7 +19,7 @@ namespace ProcessLib class BoundaryConditionCollection final { public: - BoundaryConditionCollection( + explicit BoundaryConditionCollection( std::vector<std::unique_ptr<ParameterBase>> const& parameters) : _parameters(parameters) { diff --git a/ProcessLib/Output/Output.h b/ProcessLib/Output/Output.h index 4b09525757d..4f5b828213c 100644 --- a/ProcessLib/Output/Output.h +++ b/ProcessLib/Output/Output.h @@ -83,7 +83,9 @@ public: private: struct ProcessData { - ProcessData(std::string const& filename) : pvd_file(filename) {} + explicit ProcessData(std::string const& filename) : pvd_file(filename) + { + } MeshLib::IO::PVDFile pvd_file; }; diff --git a/ProcessLib/SourceTerms/SourceTermCollection.h b/ProcessLib/SourceTerms/SourceTermCollection.h index 7de8a0747fc..b27a51e8788 100644 --- a/ProcessLib/SourceTerms/SourceTermCollection.h +++ b/ProcessLib/SourceTerms/SourceTermCollection.h @@ -17,7 +17,7 @@ namespace ProcessLib class SourceTermCollection final { public: - SourceTermCollection( + explicit SourceTermCollection( std::vector<std::unique_ptr<ParameterBase>> const& parameters) : _parameters(parameters) { diff --git a/Tests/AutoCheckTools.h b/Tests/AutoCheckTools.h index 1b121bf50c7..f28ebd5ab2d 100644 --- a/Tests/AutoCheckTools.h +++ b/Tests/AutoCheckTools.h @@ -143,7 +143,8 @@ struct progressivelySmallerGenerator using result_type = T; - progressivelySmallerGenerator(T max_value = T{1}) : _max_value(max_value) + explicit progressivelySmallerGenerator(T max_value = T{1}) + : _max_value(max_value) { } diff --git a/Tests/BaseLib/TestFunctional.cpp b/Tests/BaseLib/TestFunctional.cpp index 015f37606fb..afa519ac996 100644 --- a/Tests/BaseLib/TestFunctional.cpp +++ b/Tests/BaseLib/TestFunctional.cpp @@ -16,7 +16,7 @@ class A : private InstanceCounter<A> { public: - A(const double value) : _value(value) {} + explicit A(const double value) : _value(value) {} A(A const& other) = default; A(A&& other) : InstanceCounter(std::move(other)), _value(other._value) {} A& operator=(A const& other) { _value = other._value; return *this; } diff --git a/Tests/GeoLib/AutoCheckGenerators.h b/Tests/GeoLib/AutoCheckGenerators.h index 627acf88c67..8d9d73f7681 100644 --- a/Tests/GeoLib/AutoCheckGenerators.h +++ b/Tests/GeoLib/AutoCheckGenerators.h @@ -25,8 +25,9 @@ namespace autocheck template <typename Gen = generator<double>> struct RandomCirclePointGeneratorXY { - RandomCirclePointGeneratorXY( - MathLib::Point3d const& c = MathLib::Point3d{std::array<double, 3>{{0, 0, 0}}}, + explicit RandomCirclePointGeneratorXY( + MathLib::Point3d const& c = MathLib::Point3d{std::array<double, 3>{ + {0, 0, 0}}}, double r = 1.0) : center(c), radius(r) {} diff --git a/Tests/MaterialLib/TestMPLParseMaterial.cpp b/Tests/MaterialLib/TestMPLParseMaterial.cpp index ab25e279136..91c5b74c11f 100644 --- a/Tests/MaterialLib/TestMPLParseMaterial.cpp +++ b/Tests/MaterialLib/TestMPLParseMaterial.cpp @@ -35,7 +35,7 @@ struct Phase { std::vector<Component> component; std::vector<std::string> property; - Phase(std::size_t const componentNumber) + explicit Phase(std::size_t const componentNumber) : component(componentNumber), property(MPL::number_of_properties) { } @@ -47,7 +47,7 @@ struct Medium { std::vector<Phase> phases; std::vector<std::string> property; - Medium(std::vector<std::size_t> const& phases_) + explicit Medium(std::vector<std::size_t> const& phases_) : property(MPL::number_of_properties) { for (auto p : phases_) diff --git a/Tests/MathLib/TestGaussLegendreIntegration.cpp b/Tests/MathLib/TestGaussLegendreIntegration.cpp index aa74b687297..da34158d39b 100644 --- a/Tests/MathLib/TestGaussLegendreIntegration.cpp +++ b/Tests/MathLib/TestGaussLegendreIntegration.cpp @@ -168,7 +168,10 @@ private: } public: - FBase(std::size_t const num_coeffs) : coeffs(initCoeffs(num_coeffs)) {} + explicit FBase(std::size_t const num_coeffs) + : coeffs(initCoeffs(num_coeffs)) + { + } virtual double operator()( std::array<double, 3> const& /*coords*/) const = 0; @@ -247,7 +250,7 @@ struct FQuad final : FBase struct F3DSeparablePolynomial final : FBase { - F3DSeparablePolynomial(unsigned polynomial_degree) + explicit F3DSeparablePolynomial(unsigned polynomial_degree) : FBase(3 * polynomial_degree + 3), _degree(polynomial_degree) { } @@ -324,7 +327,7 @@ struct F3DNonseparablePolynomial final : FBase // The number of coefficients/monomials are obtained as follows: Compute the // number of combinations with repititions when drawing // polynomial_degree times from the set { x, y, z, 1 } - F3DNonseparablePolynomial(unsigned polynomial_degree) + explicit F3DNonseparablePolynomial(unsigned polynomial_degree) : FBase(binomial_coefficient(4 + polynomial_degree - 1, 4 - 1)), _degree(polynomial_degree) { diff --git a/Tests/NumLib/TestNamedFunction.cpp b/Tests/NumLib/TestNamedFunction.cpp index 481e23aa886..2fd5a402b9b 100644 --- a/Tests/NumLib/TestNamedFunction.cpp +++ b/Tests/NumLib/TestNamedFunction.cpp @@ -48,7 +48,7 @@ public: class H : public InstanceCounter<H> { public: - H(double const z) : _z(z) {} + explicit H(double const z) : _z(z) {} double h(double arg_x, double arg_y) { return arg_x * arg_y - _z; } double setZ(double const z) { -- GitLab