Pattern: Missing explicit
for constructor
Issue: -
Type conversion operators, and constructors that are callable with a single argument, must be marked explicit
in the class definition. As an exception, copy and move constructors should not be explicit
, since they do not perform type conversion. Implicit conversions can sometimes be necessary and appropriate for types that are designed to transparently wrap other types. In that case, contact your project leads to request a waiver of this rule.
Constructors that cannot be called with a single argument should usually omit explicit
. Constructors that take a single std::initializer_list
parameter should also omit explicit
, in order to support copy-initialization (e.g. MyType m = {1, 2};
).