diff --git a/DRAFT.md b/DRAFT.md index 419ef92d..fb5254ef 100644 --- a/DRAFT.md +++ b/DRAFT.md @@ -459,13 +459,13 @@ class indirect { constexpr indirect(); - constexpr indirect(allocator_arg_t, const Allocator& alloc); + explicit constexpr indirect(allocator_arg_t, const Allocator& alloc); template explicit constexpr indirect(U&& u, Us&&... us); template - constexpr indirect(allocator_arg_t, const Allocator& alloc, + explicit constexpr indirect(allocator_arg_t, const Allocator& alloc, U&& u, Us&&... us); constexpr indirect(const indirect& other); @@ -601,7 +601,7 @@ indirect(std::allocator_arg_t, Alloc, Value) -> indirect< #### X.Y.3 Constructors [indirect.ctor] ```c++ -constexpr indirect() +explicit constexpr indirect() ``` 1. _Mandates_: `is_default_constructible_v` is true. @@ -612,7 +612,7 @@ constexpr indirect() 3. _Postconditions_: `*this` is not valueless. ```c++ -constexpr indirect(allocator_arg_t, const Allocator& alloc); +explicit constexpr indirect(allocator_arg_t, const Allocator& alloc); ``` 4. _Mandates_: `is_default_constructible_v` is `true`. @@ -630,7 +630,7 @@ explicit constexpr indirect(U&& u, Us&&... us); ```c++ template -constexpr indirect(allocator_arg_t, const Allocator& alloc, U&& u, Us&& ...us); +explicit constexpr indirect(allocator_arg_t, const Allocator& alloc, U&& u, Us&& ...us); ``` 8. _Constraints_: `is_constructible_v` is `true`. @@ -1064,13 +1064,15 @@ class polymorphic { using pointer = typename allocator_traits::pointer; using const_pointer = typename allocator_traits::const_pointer; - constexpr polymorphic(); + explicit constexpr polymorphic(); + + explicit constexpr polymorphic(allocator_arg_t, const Allocator& alloc); template explicit constexpr polymorphic(in_place_type_t, Ts&&... ts); template - constexpr polymorphic(allocator_arg_t, const Allocator& alloc, + explicit constexpr polymorphic(allocator_arg_t, const Allocator& alloc, in_place_type_t, Ts&&... ts); constexpr polymorphic(const polymorphic& other); @@ -1111,7 +1113,7 @@ class polymorphic { #### X.Z.3 Constructors [polymorphic.ctor] ```c++ -constexpr polymorphic() +explicit constexpr polymorphic() ``` 1. _Mandates_: `is_default_constructible_v` is `true`, @@ -1123,7 +1125,7 @@ constexpr polymorphic() 3. _Postconditions_: `*this` is not valueless. ```c++ -constexpr polymorphic(allocator_arg_t, const Allocator& alloc); +explicit constexpr polymorphic(allocator_arg_t, const Allocator& alloc); ``` 4. _Mandates_: `is_default_constructible_v` is `true`, @@ -1143,7 +1145,7 @@ explicit constexpr polymorphic(in_place_type_t, Ts&&... ts); ```c++ template -constexpr polymorphic(allocator_arg_t, const Allocator& alloc, +explicit constexpr polymorphic(allocator_arg_t, const Allocator& alloc, in_place_type_t, Ts&&... ts); ``` diff --git a/indirect.h b/indirect.h index d36c3816..6fd0181c 100644 --- a/indirect.h +++ b/indirect.h @@ -66,14 +66,15 @@ class indirect { using pointer = typename allocator_traits::pointer; using const_pointer = typename allocator_traits::const_pointer; - constexpr indirect() + explicit constexpr indirect() requires std::is_default_constructible_v { static_assert(std::is_default_constructible_v); p_ = construct_from(alloc_); } - constexpr indirect(std::allocator_arg_t, const A& alloc) : alloc_(alloc) { + explicit constexpr indirect(std::allocator_arg_t, const A& alloc) + : alloc_(alloc) { static_assert(std::is_default_constructible_v); p_ = construct_from(alloc_); } @@ -89,7 +90,8 @@ class indirect { } template - constexpr indirect(std::allocator_arg_t, const A& alloc, U&& u, Us&&... us) + explicit constexpr indirect(std::allocator_arg_t, const A& alloc, U&& u, + Us&&... us) requires(std::constructible_from && !std::is_same_v, indirect>) : alloc_(alloc) { diff --git a/polymorphic.h b/polymorphic.h index 7bd88385..cabf9a83 100644 --- a/polymorphic.h +++ b/polymorphic.h @@ -112,7 +112,7 @@ class polymorphic { using pointer = typename allocator_traits::pointer; using const_pointer = typename allocator_traits::const_pointer; - constexpr polymorphic() { + explicit constexpr polymorphic() { static_assert(std::is_default_constructible_v); using cb_allocator = typename std::allocator_traits< A>::template rebind_alloc>; @@ -128,7 +128,8 @@ class polymorphic { } } - constexpr polymorphic(std::allocator_arg_t, const A& alloc) : alloc_(alloc) { + explicit constexpr polymorphic(std::allocator_arg_t, const A& alloc) + : alloc_(alloc) { static_assert(std::is_default_constructible_v); using cb_allocator = typename std::allocator_traits< A>::template rebind_alloc>; @@ -164,8 +165,8 @@ class polymorphic { } template - constexpr polymorphic(std::allocator_arg_t, const A& alloc, - std::in_place_type_t, Ts&&... ts) + explicit constexpr polymorphic(std::allocator_arg_t, const A& alloc, + std::in_place_type_t, Ts&&... ts) requires std::constructible_from && std::copy_constructible && (std::derived_from || std::same_as)