-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
C++23 : 「変数テンプレートの部分特殊化を許可」を追加 (close #1034)
- Loading branch information
1 parent
070dd0d
commit d936b97
Showing
4 changed files
with
43 additions
and
2 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
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
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
40 changes: 40 additions & 0 deletions
40
lang/cpp23/generalized_wording_for_partial_specializations.md
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,40 @@ | ||
# 変数テンプレートの部分特殊化を許可 | ||
* cpp23[meta cpp] | ||
|
||
## 概要 | ||
変数テンプレートの仕様として、部分特殊化の許可を意図したような仕様はあったが、部分特殊化の多くの仕様はクラステンプレートのみを対象にしていた。 | ||
|
||
C++23では部分特殊化の仕様を見直し、変数テンプレートの部分特殊化を明確に許可する。 | ||
|
||
|
||
## 例 | ||
```cpp example | ||
#include <iostream> | ||
|
||
template <class T> | ||
constexpr T zero = 0; | ||
|
||
template <class T> | ||
constexpr T* zero<T*> = nullptr; | ||
|
||
int main() { | ||
int x = zero<int>; | ||
int* y = zero<int*>; | ||
|
||
std::cout << x << std::endl; | ||
std::cout << y << std::endl; | ||
} | ||
``` | ||
|
||
### 出力例 | ||
``` | ||
0 | ||
(nil) | ||
``` | ||
|
||
## 関連項目 | ||
- [C++14 変数テンプレート](/lang/cpp14/variable_templates.md) | ||
|
||
|
||
## 参照 | ||
- [P2096R2 Generalized wording for partial specializations](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2096r2.html) |