mirror of
https://github.com/AnthonyCalandra/modern-cpp-features.git
synced 2025-12-17 10:04:35 +03:00
Fix compound requirement code example (#127)
This commit is contained in:
4
CPP20.md
4
CPP20.md
@@ -221,9 +221,9 @@ g(baz{}); // PASS.
|
|||||||
```c++
|
```c++
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept C = requires(T x) {
|
concept C = requires(T x) {
|
||||||
{*x} -> typename T::inner; // the type of the expression `*x` is convertible to `T::inner`
|
{*x} -> std::convertible_to<typename T::inner>; // the type of the expression `*x` is convertible to `T::inner`
|
||||||
{x + 1} -> std::same_as<int>; // the expression `x + 1` satisfies `std::same_as<decltype((x + 1))>`
|
{x + 1} -> std::same_as<int>; // the expression `x + 1` satisfies `std::same_as<decltype((x + 1))>`
|
||||||
{x * 1} -> T; // the type of the expression `x * 1` is convertible to `T`
|
{x * 1} -> std::convertible_to<T>; // the type of the expression `x * 1` is convertible to `T`
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
* **Nested requirements** - denoted by the `requires` keyword, specify additional constraints (such as those on local parameter arguments).
|
* **Nested requirements** - denoted by the `requires` keyword, specify additional constraints (such as those on local parameter arguments).
|
||||||
|
|||||||
@@ -324,9 +324,9 @@ g(baz{}); // PASS.
|
|||||||
```c++
|
```c++
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept C = requires(T x) {
|
concept C = requires(T x) {
|
||||||
{*x} -> typename T::inner; // the type of the expression `*x` is convertible to `T::inner`
|
{*x} -> std::convertible_to<typename T::inner>; // the type of the expression `*x` is convertible to `T::inner`
|
||||||
{x + 1} -> std::same_as<int>; // the expression `x + 1` satisfies `std::same_as<decltype((x + 1))>`
|
{x + 1} -> std::same_as<int>; // the expression `x + 1` satisfies `std::same_as<decltype((x + 1))>`
|
||||||
{x * 1} -> T; // the type of the expression `x * 1` is convertible to `T`
|
{x * 1} -> std::convertible_to<T>; // the type of the expression `x * 1` is convertible to `T`
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
* **Nested requirements** - denoted by the `requires` keyword, specify additional constraints (such as those on local parameter arguments).
|
* **Nested requirements** - denoted by the `requires` keyword, specify additional constraints (such as those on local parameter arguments).
|
||||||
|
|||||||
Reference in New Issue
Block a user