Skip to content

Commit f9f61e8

Browse files
committed
annotations_of : consteval-only型を実行時に使ってしまっていたのを修正
1 parent 97f4d83 commit f9f61e8

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

reference/meta/annotations_of.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ struct [[=Label{std::define_static_string("my struct")}, =42]] S {};
3030
3131
int main() {
3232
constexpr auto annots = std::define_static_array(std::meta::annotations_of(^^S));
33-
std::println("アノテーション数: {}", annots.size());
33+
// annotsはconsteval-only型のため、実行時に使うにはサイズなどを
34+
// 定数式としてあらかじめ取り出しておく必要がある
35+
constexpr std::size_t count = annots.size();
36+
std::println("アノテーション数: {}", count);
3437
3538
template for (constexpr auto a : annots) {
3639
// アノテーションの型名を出力

0 commit comments

Comments
 (0)