Skip to content

Files

Latest commit

 

History

History
14 lines (7 loc) · 921 Bytes

runtime-explicit.md

File metadata and controls

14 lines (7 loc) · 921 Bytes

Pattern: Missing explicit for constructor

Issue: -

Description

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};).

Further Reading