style: declare single argument constructors as `explicit`
This PR declares all of the single argument constructors as explicit. This makes the implicit conversion impossible. Cf.
Why cant this be done for multi param constructors?
Why cant this be done for multi param constructors?
What is implicit conversion? Please have a look at this example:
struct S
{
int val_a;
int val_b;
S(int in_val) : val_a(in_val), val_b(10*in_val) {}
};
int main()
{
int some_int = 17;
S some_s = some_int; // implicit conversion from int to S
return 0;
}
Here an integer some_int is implicitly converted to an object of class S. We could make the conversion explicit by:
S some_other_s = S(some_int); // we explicitly call the constructor of S
Answering your question: it is simply not possible in C++ to have implicit conversion of several variables.
Please have a look at:
- https://en.cppreference.com/w/cpp/language/explicit
- https://en.cppreference.com/w/cpp/language/converting_constructor
Please change the PR merge to dev branch. We will merge in main once we move for release after thorough testing.