You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -229,8 +229,8 @@ auto drawCircle ()
229
229
}
230
230
```
231
231
232
-
> [!NOTE]
233
-
> `is<'trait'>` denotes a C++ concept
232
+
`is<'trait'>` is a C++ concept provided by the library that checks the type without `const` or `volatile` modifiers and as a non-reference type (i.e. the result of `std::remove_cvref_t`).
233
+
This makes it easier to use this concept for forwarding references.
234
234
235
235
### traits can have multiple behaviors
236
236
@@ -397,7 +397,7 @@ struct Any final
397
397
};
398
398
399
399
template <typename T, typename U>
400
-
concept not_same_as = not std::same_as<T, U>;
400
+
concept not_same_as = not std::same_as<std::remove_cvref_t<T>, U>; // sic! T might be deduced to a reference type
401
401
```
402
402
403
403
On the other hand, with a constraint ...
@@ -419,6 +419,8 @@ struct Any
419
419
> [!NOTE]
420
420
> `is<'constraint'>` is equivalent to `is<trait{'constraint'}>`
421
421
422
+
This check will work even when value will be deduced as reference type.
423
+
422
424
#### constraints can be used to force strong(er) coupling
423
425
424
426
It may be advantageous to manage all implementations of a trait in a class hierarchy because, for example, the IDE supports inheritance particularly well.
@@ -678,7 +680,7 @@ constexpr auto get (impl_for<WithSummary, Tweet>)
678
680
}
679
681
```
680
682
681
-
> [!NOTE]
683
+
> [!TIP]
682
684
> The short syntax also works for multiple methods and lambda implementations.
683
685
684
686
We can now use the type in a function that requires both traits.
@@ -902,7 +904,7 @@ auto printName ()
902
904
## Tips for use
903
905
904
906
Since traits are essentially used within `is<...>`, the trait names should be chosen appropriately to maintain a natural reading flow.
905
-
For this reason, a noun is used in all examples or the paraphrase *with ... behavior* instead of *has ... behavior* is used.
907
+
For this reason, a noun or the paraphrase *with ... behavior* instead of *has ... behavior* is used in all examples .
0 commit comments