-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
> https://mp.weixin.qq.com/s/t5_Up2YZEZt1NLbvgYz9FQ + | ||
> https://www.zhihu.com/question/24301047/answer/83422523 |
20 changes: 20 additions & 0 deletions
20
_posts/C-Cpp/2024-03-24-cpp-explicit-template-and-typename-declaration.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<T>::type *a; // <2> | ||
result.template emplace<0>(something); | ||
typename std::decay<T>::type *a; | ||
} | ||
<1> the result of whether `result.emplace` is less than 0 compare with `something` | ||
<2> `std::decay<T>::type` is a value then times `a` | ||
``` |