In C++ standard the copy constructor of optional is defined as follows:
constexpr optional(const optional& rhs);
Effects: If rhs contains a value, direct-non-list-initializes the contained value with *rhs.
If rhs contains a value, it will get copy constructed and since the copy constructor is defined as deleted unless is_copy_constructible_v is true, why does the standard use the more generic "direct-non-list-initialization" instead of saying "If rhs contains a value, it 'copy constructs' the contained value with *rhs"?
If
A a, then bothA a1(a)andA a2{a}are direct-initialized. However, ifAhas an initializer-list constructor, it will always be preferred over other constructors for brace-init-initializers (list initialization). IfAhas both a copy constructor and an initializer-list constructor, the latter is used forA a2{a}.The standard requires that the direct-initializing copy constructor
A(const A&)is used, and the direct-list-initializing constructor must not be used if a copy constructor is deleted.