Skip to content

Commit 9afffee

Browse files
string_viewは構造的型ではないのでアノテーションに使用できず、文字列リテラルはdefine_static_stringでラップする必要がある
Co-authored-by: Raclamusi <61970673+Raclamusi@users.noreply.github.com>
1 parent 741186c commit 9afffee

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lang/cpp26/reflection.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,11 @@ struct [[=1]] Annotated {
228228
アノテーションの式は構造的型でなければならない。アノテーションの取得には[`annotations_of()`](/reference/meta/annotations_of.md)[`annotations_of_with_type()`](/reference/meta/annotations_of_with_type.md)メタ関数を使用する。
229229

230230
```cpp
231-
struct Name { std::string_view value; };
231+
struct Name { const char* value; };
232232

233-
struct [[=Name{"点"}]] Point {
234-
[[=Name{"x座標"}]] int x;
235-
[[=Name{"y座標"}]] int y;
233+
struct [[=Name{std::define_static_string("点")}]] Point {
234+
[[=Name{std::define_static_string("x座標")}]] int x;
235+
[[=Name{std::define_static_string("y座標")}]] int y;
236236
};
237237

238238
// メンバのアノテーションを取得

0 commit comments

Comments
 (0)