From 559d944a86807031ea6cf81cb10aec8991454a21 Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Thu, 3 Dec 2020 14:10:42 -0500 Subject: [PATCH] mark constructors in Function* as explicit While not strictly backwards compatible, I think it is a very dangerous design to have things convert to Function automatically including an int. Stop this by marking them explicit. --- include/deal.II/base/function.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/include/deal.II/base/function.h b/include/deal.II/base/function.h index 3fed52cf6b..3ea52c8b08 100644 --- a/include/deal.II/base/function.h +++ b/include/deal.II/base/function.h @@ -174,8 +174,8 @@ public: * (which defaults to one, i.e. a scalar function), and the time variable, * which defaults to zero. */ - Function(const unsigned int n_components = 1, - const time_type initial_time = 0.0); + explicit Function(const unsigned int n_components = 1, + const time_type initial_time = 0.0); /** * Copy constructor. @@ -414,22 +414,22 @@ namespace Functions * Constructor; set values of all components to the provided one. The * default number of components is one. */ - ConstantFunction(const RangeNumberType value, - const unsigned int n_components = 1); + explicit ConstantFunction(const RangeNumberType value, + const unsigned int n_components = 1); /** * Constructor; takes an std::vector object as an * argument. The number of components is determined by * values.size(). */ - ConstantFunction(const std::vector &values); + explicit ConstantFunction(const std::vector &values); /** * Constructor; takes an Vector object as an * argument. The number of components is determined by * values.size(). */ - ConstantFunction(const Vector &values); + explicit ConstantFunction(const Vector &values); /** * Constructor; uses whatever stores in [begin_ptr, begin_ptr+n_components) @@ -513,7 +513,7 @@ namespace Functions /** * Constructor. The number of components is preset to one. */ - ZeroFunction(const unsigned int n_components = 1); + explicit ZeroFunction(const unsigned int n_components = 1); }; } // namespace Functions @@ -709,7 +709,7 @@ public: * value, convert this into an object that matches the Function interface. */ - ScalarFunctionFromFunctionObject( + explicit ScalarFunctionFromFunctionObject( const std::function &)> &function_object); /** @@ -878,7 +878,7 @@ public: * method will trigger an exception, unless you first call the * set_function_gradients() method. */ - FunctionFromFunctionObjects( + explicit FunctionFromFunctionObjects( const std::vector &)>> & values, const double initial_time = 0.0); @@ -1011,7 +1011,7 @@ public: * the first argument. This should be such that the entire tensor_function * fits inside the n_component length return vector. */ - VectorFunctionFromTensorFunction( + explicit VectorFunctionFromTensorFunction( const TensorFunction<1, dim, RangeNumberType> &tensor_function, const unsigned int selected_component = 0, const unsigned int n_components = dim); -- 2.39.5