Skip to content

Commit

Permalink
Rename exposition only variables (jbcoe#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
Twon authored Nov 28, 2023
1 parent 38b1445 commit 8879cf8
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions DRAFT.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ should not be considered in isolation.

* Require `T` to satisfy the requirements of `Cpp17Destructible`.

* Rename exposition only variables `p_` to `p` and `allocator_` to `alloc`.


### Changes in R3

* Add explicit to constructors.
Expand Down Expand Up @@ -532,8 +535,6 @@ move assignment, or swapping of the allocator only if
```c++
template <class T, class Allocator = allocator<T>>
class indirect {
pointer p_; // exposition only
Allocator allocator_; // exposition only
public:
using value_type = T;
using allocator_type = Allocator;
Expand Down Expand Up @@ -670,6 +671,10 @@ class indirect {
template <class U>
friend constexpr auto operator<=>(
const U& lhs, const indirect& rhs) noexcept(see below);

private:
pointer p; // exposition only
Allocator alloc; // exposition only
};

template <typename Value>
Expand All @@ -689,7 +694,7 @@ explicit constexpr indirect()
1. _Mandates_: `is_default_constructible_v<T>` is true.

2. _Effects_: Constructs an `indirect` owning a default constructed `T`
and stores the address in `p_`. `allocator_` is default constructed.
and stores the address in `p`. `alloc` is default constructed.

3. _Postconditions_: `*this` is not valueless.

Expand All @@ -703,7 +708,7 @@ explicit constexpr indirect(allocator_arg_t, const Allocator& alloc);
5. _Mandates_: `is_default_constructible_v<T>` is `true`.
6. _Effects_: Constructs an `indirect` owning a default constructed `T` and
stores the address in `p_`. `allocator_` is direct-non-list-initialized with `alloc`.
stores the address in `p`. `alloc` is direct-non-list-initialized with `alloc`.
7. _Postconditions_: `*this` is not valueless.
Expand All @@ -723,13 +728,13 @@ explicit constexpr indirect(U&& u, Us&&... us);

```c++
template <class U, class... Us>
explicit constexpr indirect(allocator_arg_t, const Allocator& alloc, U&& u, Us&& ...us);
explicit constexpr indirect(allocator_arg_t, const Allocator& a, U&& u, Us&& ...us);
```
11. _Constraints_: `is_constructible_v<T, U, Us...>` is `true`.
`is_same_v<remove_cvref_t<U>, indirect>` is `false`.
12. _Effects_: `allocator_` is direct-non-list-initialized with `alloc`.
12. _Effects_: `alloc` is direct-non-list-initialized with `a`.
DRAFTING NOTE: based on https://eel.is/c++draft/func.wrap#func.con-6
Expand Down Expand Up @@ -770,7 +775,7 @@ constexpr indirect(indirect&& other) noexcept;
is `true` --end note]_

23. _Effects_: Constructs an `indirect` that takes ownership of the `other`'s owned object and stores the address in `p_`.
`allocator_` is initialized by construction from `other.allocator_`.
`alloc` is initialized by construction from `other.alloc`.

24. _Postconditions_: `other` is valueless.

Expand Down Expand Up @@ -811,12 +816,12 @@ constexpr indirect& operator=(const indirect& other);
Otherwise, if either:
- `is_copy_assignable_v<T>` is `false` and `is_nothrow_copy_constructible_v<T>` is `false`, or
- `allocator_traits<allocator_type>::propagate_on_container_copy_assignment::value` is `true` and
`allocator_ == other.allocator_` is `false`, or
`alloc == other.alloc` is `false`, or
- `*this` is valueless
then, equivalent to `*this = indirect(allocator_arg, allocator_traits<allocator_type>::propagate_on_container_copy_assignment::value ? other.allocator_ : allocator_, *other)`
then, equivalent to `*this = indirect(allocator_arg, allocator_traits<allocator_type>::propagate_on_container_copy_assignment::value ? other.alloc : alloc, *other)`
Otherwise, if `is_copy_assignable_v<T>` is `true`, then equivalent to `**this = *other`,
Otherwise, equivalent to:
- `(allocator_traits<allocator_type>::destruct(alloc_, p_), allocator_traits<allocator_type>::construct(alloc_, p_, *other))`
- `(allocator_traits<allocator_type>::destruct(alloc, p), allocator_traits<allocator_type>::construct(a, p, *other))`

4. _Postconditions_: `*this` is not valueless.

Expand All @@ -834,7 +839,7 @@ _Mandates_: `is_move_constructible_v<T>` is `true`.

7. _Effects_: If `&other == this`, then has no effects. Otherwise, if
`allocator_traits<allocator_type>::propagate_on_container_move_assignment::value
== true`, `allocator_` is set to the allocator of `other`. If allocator is
== true`, `alloc` is set to the allocator of `other`. If allocator is
propagated or is equal to the allocator of `other`, destroys the owned object,
if any, then takes ownership of the object owned by `other`. Otherwise,
destroys the owned object if any, then move constructs an object from the
Expand Down Expand Up @@ -1162,7 +1167,7 @@ operation.
```c++
template <class T, class Allocator = allocator<T>>
class polymorphic {
Allocator allocator_; // exposition only
Allocator alloc; // exposition only
public:
using value_type = T;
using allocator_type = Allocator;
Expand Down Expand Up @@ -1225,7 +1230,7 @@ explicit constexpr polymorphic()
`is_copy_constructible_v<T>` is `true`.

2. _Effects_: Constructs a polymorphic owning a default constructed `T`.
`allocator_` is default constructed.
`alloc` is default constructed.

3. _Postconditions_: `*this` is not valueless.

Expand All @@ -1240,7 +1245,7 @@ explicit constexpr polymorphic(allocator_arg_t, const Allocator& alloc);
`is_copy_constructible_v<T>` is `true`.
6. _Effects_: Constructs a polymorphic owning a default constructed `T`.
`allocator_` is direct-non-list-initialized with alloc.
`alloc` is direct-non-list-initialized with alloc.
7. _Postconditions_: `*this` is not valueless.
Expand All @@ -1256,14 +1261,14 @@ explicit constexpr polymorphic(in_place_type_t<U>, Ts&&... ts);

```c++
template <class U, class... Ts>
explicit constexpr polymorphic(allocator_arg_t, const Allocator& alloc,
explicit constexpr polymorphic(allocator_arg_t, const Allocator& a,
in_place_type_t<U>, Ts&&... ts);
```
10. _Constraints_: `is_base_of_v<T, U>` is `true` and `is_constructible_v<U, Ts...>` is
`true` and `is_copy_constructible_v<U>` is `true`.
11. _Effects_: `allocator_` is direct-non-list-initialized with alloc.
11. _Effects_: `alloc` is direct-non-list-initialized with `a`.
12. _Postconditions_: `*this` is not valueless. The owned instance targets an object of type `U`
constructed with `std::forward<Ts>(ts)...`.
Expand All @@ -1273,17 +1278,17 @@ constexpr polymorphic(const polymorphic& other);
```

13. _Effects_: Equivalent to
`polymorphic(allocator_arg_t{}, allocator_traits<allocator_type>::select_on_container_copy_construction(other.alloc_), other)`.
`polymorphic(allocator_arg_t{}, allocator_traits<allocator_type>::select_on_container_copy_construction(other.alloc), other)`.

```c++
constexpr polymorphic(allocator_arg_t, const Allocator& alloc,
constexpr polymorphic(allocator_arg_t, const Allocator& a,
const polymorphic& other);
```
14. _Preconditions_: `other` is not valueless.
15. _Effects_: Constructs a polymorphic owning an instance of `T` created with the
copy constructor of the object owned by `other`. `allocator_` is direct-non-list-initialized with alloc.
copy constructor of the object owned by `other`. `alloc` is direct-non-list-initialized with `a`.
16. _Postconditions_: `*this` is not valueless.
Expand All @@ -1294,7 +1299,7 @@ constexpr polymorphic(polymorphic&& other) noexcept;
17. _Effects_: Equivalent to `polymorphic(allocator_arg_t{}, Allocator(std::move(other.alloc_)), other)`.

```c++
constexpr polymorphic(allocator_arg_t, const Allocator& alloc,
constexpr polymorphic(allocator_arg_t, const Allocator& a,
polymorphic&& other) noexcept;
```
Expand All @@ -1303,7 +1308,7 @@ constexpr polymorphic(allocator_arg_t, const Allocator& alloc,
19. _Effects_: Constructs a polymorphic that takes ownership of the object owned
by `other`.
`allocator_` is direct-non-list-initialized with `alloc`.
`alloc` is direct-non-list-initialized with `a`.
20. _Postconditions_: `other` is valueless.
Expand Down

0 comments on commit 8879cf8

Please sign in to comment.