From 476fa587375e8805fb8d2fbd7fb15c5bb592a1cb Mon Sep 17 00:00:00 2001 From: xac Date: Sun, 24 Mar 2024 12:27:08 +0800 Subject: [PATCH] explicit typename --- _drafts/memory-order.adoc | 2 ++ ...cit-template-and-typename-declaration.adoc | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 _drafts/memory-order.adoc create mode 100644 _posts/C-Cpp/2024-03-24-cpp-explicit-template-and-typename-declaration.adoc diff --git a/_drafts/memory-order.adoc b/_drafts/memory-order.adoc new file mode 100644 index 0000000..6ac9c3d --- /dev/null +++ b/_drafts/memory-order.adoc @@ -0,0 +1,2 @@ +> https://mp.weixin.qq.com/s/t5_Up2YZEZt1NLbvgYz9FQ + +> https://www.zhihu.com/question/24301047/answer/83422523 \ No newline at end of file diff --git a/_posts/C-Cpp/2024-03-24-cpp-explicit-template-and-typename-declaration.adoc b/_posts/C-Cpp/2024-03-24-cpp-explicit-template-and-typename-declaration.adoc new file mode 100644 index 0000000..b31f804 --- /dev/null +++ b/_posts/C-Cpp/2024-03-24-cpp-explicit-template-and-typename-declaration.adoc @@ -0,0 +1,20 @@ += Cpp Explicit template and typename Declaration +:revdate: 2024-03-24 +:page-category: Cpp +:page-tags: [cpp] + +*Compilers may hard to tell the real meaning without explicit declaration* + +Misunderstanding by compiler: + +```cpp +void func() { + result.emplace<0>(something); // <1> + std::decay::type *a; // <2> + + result.template emplace<0>(something); + typename std::decay::type *a; +} +<1> the result of whether `result.emplace` is less than 0 compare with `something` +<2> `std::decay::type` is a value then times `a` +``` \ No newline at end of file