From d6deac54dd372c946942637636846893694ce521 Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Wed, 12 Apr 2023 22:57:27 +0200 Subject: c++: improve void_t explanation --- src/development/c++.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/development/c++.md') 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...` expressions is ill-formed, the template specialization for `is_valid` will be removed from the candidate set due to [SFINAE][sfinae]. ```cpp -template -struct is_valid : std::false_type {}; - -template -struct is_valid().some_fun1()), - decltype(std::declval().some_fun2()) - >> : std::true_type {}; +{{#include c++/tmpl-void_t.cc:3:45}} ``` > `std::declval()` 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:}} -- cgit v1.2.3