aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/development/c++.md
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2023-04-12 22:57:27 +0200
committerJohannes Stoelp <johannes.stoelp@gmail.com>2023-04-12 22:57:27 +0200
commitd6deac54dd372c946942637636846893694ce521 (patch)
tree2bcd7d8180cdc6f219c1ae616c9ef42497970b34 /src/development/c++.md
parenta6d3ae16736d7746ad6827f10c299ad84aa78a5b (diff)
downloadnotes-d6deac54dd372c946942637636846893694ce521.tar.gz
notes-d6deac54dd372c946942637636846893694ce521.zip
c++: improve void_t explanation
Diffstat (limited to 'src/development/c++.md')
-rw-r--r--src/development/c++.md12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/development/c++.md b/src/development/c++.md
index 9dc8fb0..6cdc251 100644
--- a/src/development/c++.md
+++ b/src/development/c++.md
@@ -58,17 +58,13 @@ of the `decltype(std:declval<T>...` expressions is ill-formed, the template
specialization for `is_valid` will be removed from the candidate set due to
[SFINAE][sfinae].
```cpp
-template<typename T, typename = void>
-struct is_valid : std::false_type {};
-
-template<typename T>
-struct is_valid<T, std::void_t<
- decltype(std::declval<T>().some_fun1()),
- decltype(std::declval<T>().some_fun2())
- >> : std::true_type {};
+{{#include c++/tmpl-void_t.cc:3:45}}
```
> `std::declval<T>()` creates an instance of type T in an unevaluated context.
+A more detailed description is available in the SO discussion [How does
+`void_t` work](https://stackoverflow.com/a/27688405).
+
## Template selection with partially / fully specializations.
```cpp
{{#include c++/tmpl-pair.cc:3:}}