From: Timo Heister Date: Thu, 3 Dec 2020 19:10:42 +0000 (-0500) Subject: mark constructors in Function* as explicit X-Git-Tag: v9.3.0-rc1~805^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=559d944a86807031ea6cf81cb10aec8991454a21;p=dealii.git 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. --- 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);