Skip to content

Commit 6061559

Browse files
committed
P2231R1: some functions will be constexpr in C++23
1 parent 31cfbe3 commit 6061559

File tree

5 files changed

+37
-8
lines changed

5 files changed

+37
-8
lines changed

reference/variant/variant/emplace.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,28 @@
77

88
```cpp
99
template <class T, class... Args>
10-
T& emplace(Args&&... args); // (1)
10+
T& emplace(Args&&... args); // (1) C++17
11+
template <class T, class... Args>
12+
constexpr T& emplace(Args&&... args); // (1) C++23
1113

1214
template <class T, class U, class... Args>
13-
T& emplace(std::initializer_list<U> il, Args&&... args); // (2)
15+
T& emplace(std::initializer_list<U> il, Args&&... args); // (2) C++17
16+
template <class T, class U, class... Args>
17+
constexpr T& emplace(std::initializer_list<U> il, Args&&... args); // (2) C++23
1418

1519
template <std::size_t I, class... Args>
1620
variant_alternative_t<I, variant<Types...>>&
17-
emplace(Args&&... args); // (3)
21+
emplace(Args&&... args); // (3) C++17
22+
template <std::size_t I, class... Args>
23+
constexpr variant_alternative_t<I, variant<Types...>>&
24+
emplace(Args&&... args); // (3) C++23
1825

1926
template <std::size_t I, class U, class... Args>
2027
variant_alternative_t<I, variant<Types...>>&
21-
emplace(std::initializer_list<U> il, Args&&... args); // (4)
28+
emplace(std::initializer_list<U> il, Args&&... args); // (4) C++17
29+
template <std::size_t I, class U, class... Args>
30+
constexpr variant_alternative_t<I, variant<Types...>>&
31+
emplace(std::initializer_list<U> il, Args&&... args); // (4) C++23
2232
```
2333
* variant_alternative_t[link /reference/variant/variant_alternative.md]
2434
@@ -177,3 +187,6 @@ int main()
177187
- [Clang](/implementation.md#clang): 4.0.1
178188
- [GCC](/implementation.md#gcc): 7.3
179189
- [Visual C++](/implementation.md#visual_cpp): ??
190+
191+
## 参照
192+
- [P2231R1 Missing `constexpr` in `std::optional` and `std::variant`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2231r1.html)

reference/variant/variant/op_assign.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ constexpr variant& operator=(const variant& rhs); // (1)
1010
constexpr variant& operator=(variant&& t) noexcept(see below); // (2)
1111

1212
template <class T>
13-
variant& operator=(T&& rhs) noexcept(see below); // (3)
13+
variant& operator=(T&& rhs) noexcept(see below); // (3) C++17
14+
template <class T>
15+
constexpr variant& operator=(T&& rhs) noexcept(see below); // (3) C++23
1416
```
1517

1618
## 概要
@@ -193,3 +195,4 @@ int main()
193195
## 参照
194196
- [P0608R3 A sane variant converting constructor](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0608r3.html)
195197
- [P0602R4 `variant` and `optional` should propagate copy/move triviality](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0602r4.html)
198+
- [P2231R1 Missing `constexpr` in `std::optional` and `std::variant`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2231r1.html)

reference/variant/variant/op_destructor.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
* cpp17[meta cpp]
77

88
```cpp
9-
~variant();
9+
~variant(); // C++17
10+
constexpr ~variant(); // C++23
1011
```
1112

1213
## 概要
@@ -34,3 +35,6 @@
3435

3536
## 関連項目
3637
- [`std::is_trivially_destructible`](/reference/type_traits/is_trivially_destructible.md)
38+
39+
## 参照
40+
- [P2231R1 Missing `constexpr` in `std::optional` and `std::variant`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2231r1.html)

reference/variant/variant/swap.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
* cpp17[meta cpp]
77

88
```cpp
9-
void swap(variant& rhs) noexcept(see below);
9+
void swap(variant& rhs) noexcept(see below); // C++17
10+
constexpr void swap(variant& rhs) noexcept(see below); // C++23
1011
```
1112
1213
## 概要
@@ -69,3 +70,6 @@ int main()
6970
- [Clang](/implementation.md#clang): 4.0.1
7071
- [GCC](/implementation.md#gcc): 7.3
7172
- [Visual C++](/implementation.md#visual_cpp): ??
73+
74+
## 参照
75+
- [P2231R1 Missing `constexpr` in `std::optional` and `std::variant`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2231r1.html)

reference/variant/variant/swap_free.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
```cpp
88
namespace std {
99
template <class... Types>
10-
void swap(variant<Types...>& x, variant<Types...>& y) noexcept(see below);
10+
void swap(variant<Types...>& x, variant<Types...>& y) noexcept(see below); // C++17
11+
template <class... Types>
12+
constexpr void swap(variant<Types...>& x, variant<Types...>& y) noexcept(see below); // C++23
1113
}
1214
```
1315
@@ -71,3 +73,6 @@ int main()
7173
- [Clang](/implementation.md#clang): 4.0.1
7274
- [GCC](/implementation.md#gcc): 7.3
7375
- [Visual C++](/implementation.md#visual_cpp): ??
76+
77+
## 参照
78+
- [P2231R1 Missing `constexpr` in `std::optional` and `std::variant`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2231r1.html)

0 commit comments

Comments
 (0)