回答編集履歴

1

update

2017/05/08 01:12

投稿

yohhoy
yohhoy

スコア6191

test CHANGED
@@ -17,3 +17,23 @@
17
17
 
18
18
 
19
19
  Demo: [https://wandbox.org/permlink/KE2Y3rrXjRdKwxjA](https://wandbox.org/permlink/KE2Y3rrXjRdKwxjA)
20
+
21
+
22
+
23
+ ---
24
+
25
+ **追記:** 上記コードはGCCで通りますが、Clangではエラーになります。
26
+
27
+
28
+
29
+ StackOverflowに同じトピック"[Can I implement an autonomous `self` member type in C++?](http://stackoverflow.com/questions/21143835/)"があり、どうもC++14(C++1z/17でも?)現在は実現不可能な気がしてきました。
30
+
31
+
32
+
33
+ C++14(N3937) [expr.prim.general]/paragraph 3によれば、`this`キーワードをstaticメンバ関数の宣言中で用いるのはNGと読めます(太字部)。C++1z/17(N4659)では[expr.prim.this]/p2。
34
+
35
+
36
+
37
+ > If a declaration declares a member function or member function template of a class `X`, the expression `this` is a prvalue of type "pointer to __cv-qualifier-seq__ `X`" [...] It shall not appear before the optional __cv-qualifier-seq__ and **it shall not appear within the declaration of a static member function** (although its type and value category are defined within a static member function as they are within a non-static member function). [...]
38
+
39
+