From 4681e861efcdf9b0b73e3803e70712bc55162863 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 8 Aug 2026 10:38:18 +0900 Subject: feat(slides): improve slide controller --- .../index.html | 60 ++++++++++++---------- 1 file changed, 32 insertions(+), 28 deletions(-) (limited to 'services/nuldoc/public/blog/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes') diff --git a/services/nuldoc/public/blog/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html b/services/nuldoc/public/blog/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html index db3f0334..ea909c94 100644 --- a/services/nuldoc/public/blog/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html +++ b/services/nuldoc/public/blog/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html @@ -15,7 +15,7 @@ 【C++】 属性構文の属性名にはキーワードが使える|REPL: Rest-Eat-Program Loop - +
@@ -72,41 +72,44 @@ タイトル落ち。まずはこのコードを見て欲しい。

-
#include <iostream> -
-
[[alignas]] [[alignof]] [[and]] [[and_eq]] [[asm]] [[auto]] [[bitand]] -
[[bitor]] [[bool]] [[break]] [[case]] [[catch]] [[char]] [[char16_t]] -
[[char32_t]] [[class]] [[compl]] [[const]] [[const_cast]] [[constexpr]] -
[[continue]] [[decltype]] [[default]] [[delete]] [[do]] [[double]] -
[[dynamic_cast]] [[else]] [[enum]] [[explicit]] [[export]] [[extern]] [[false]] -
[[final]] [[float]] [[for]] [[friend]] [[goto]] [[if]] [[inline]] [[int]] -
[[long]] [[mutable]] [[namespace]] [[new]] [[noexcept]] [[not]] [[not_eq]] -
[[nullptr]] [[operator]] [[or]] [[or_eq]] [[override]] [[private]] -
[[protected]] [[public]] [[register]] [[reinterpret_cast]] [[return]] [[short]] -
[[signed]] [[sizeof]] [[static]] [[static_assert]] [[static_cast]] [[struct]] -
[[switch]] [[template]] [[this]] [[thread_local]] [[throw]] [[true]] [[try]] -
[[typedef]] [[typeid]] [[typename]] [[union]] [[unsigned]] -
[[virtual]] [[void]] [[volatile]] [[wchar_t]] [[while]] [[xor]] [[xor_eq]] -
// [[using]] -
int main() { -
std::cout << "Hello, World!" << std::endl; -
}
+
#include <iostream>
+
+[[alignas]] [[alignof]] [[and]] [[and_eq]] [[asm]] [[auto]] [[bitand]]
+[[bitor]] [[bool]] [[break]] [[case]] [[catch]] [[char]] [[char16_t]]
+[[char32_t]] [[class]] [[compl]] [[const]] [[const_cast]] [[constexpr]]
+[[continue]] [[decltype]] [[default]] [[delete]] [[do]] [[double]]
+[[dynamic_cast]] [[else]] [[enum]] [[explicit]] [[export]] [[extern]] [[false]]
+[[final]] [[float]] [[for]] [[friend]] [[goto]] [[if]] [[inline]] [[int]]
+[[long]] [[mutable]] [[namespace]] [[new]] [[noexcept]] [[not]] [[not_eq]]
+[[nullptr]] [[operator]] [[or]] [[or_eq]] [[override]] [[private]]
+[[protected]] [[public]] [[register]] [[reinterpret_cast]] [[return]] [[short]]
+[[signed]] [[sizeof]] [[static]] [[static_assert]] [[static_cast]] [[struct]]
+[[switch]] [[template]] [[this]] [[thread_local]] [[throw]] [[true]] [[try]]
+[[typedef]] [[typeid]] [[typename]] [[union]] [[unsigned]]
+[[virtual]] [[void]] [[volatile]] [[wchar_t]] [[while]] [[xor]] [[xor_eq]]
+// [[using]]
+int main() {
+    std::cout << "Hello, World!" << std::endl;
+}
+

コンパイラのバージョン

-
$ clang++ --version -
Apple clang version 11.0.0 (clang-1100.0.33.8) -
Target: x86_64-apple-darwin19.6.0 -
Thread model: posix -
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
+
$ clang++ --version
+Apple clang version 11.0.0 (clang-1100.0.33.8)
+Target: x86_64-apple-darwin19.6.0
+Thread model: posix
+InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
+

コンパイルコマンド (C++17 指定)

-
$ clang --std=c++17 hoge.cpp
+
$ clang --std=c++17 hoge.cpp
+

この記事から得られるものはこれ以上ないので以下は蛇足になる。 @@ -136,8 +139,9 @@ 上のコードでは [[using]] をコメントアウトしているが、これは using キーワードのみ属性構文の中で意味を持つからであり、このコメントアウトを外すとコンパイルに失敗する。

-
// using の例 -
[[using foo: attr1, attr2]] int x; // [[foo::attr1, foo::attr2]] の糖衣構文
+
// using の例
+[[using foo: attr1, attr2]] int x; // [[foo::attr1, foo::attr2]] の糖衣構文
+

C++17 の仕様も見てみる (正確には標準化前のドラフト)。 -- cgit v1.3.1