88namespace std ::meta {
99 class exception : public std::exception {
1010 public:
11- exception(u8string_view msg, info from, std::source_location where = std::source_location::current());
12- const char* what() const noexcept override;
13- const char8_t* u8what() const noexcept;
14- consteval info from() const;
15- consteval std::source_location where() const;
11+ consteval exception(std::u8string_view what, info from,
12+ std::source_location where = std::source_location::current()) noexcept;
13+
14+ consteval exception(std::string_view what, info from,
15+ std::source_location where = std::source_location::current()) noexcept;
16+
17+ exception(const exception&) = default;
18+ exception(exception&&) = default;
19+
20+ exception& operator=(const exception&) = default;
21+ exception& operator=(exception&&) = default;
22+
23+ consteval const char* what() const noexcept override;
24+ consteval std::u8string_view u8what() const noexcept;
25+ consteval info from() const noexcept;
26+ consteval std::source_location where() const noexcept;
1627 };
1728}
1829```
@@ -22,14 +33,15 @@ namespace std::meta {
2233## 概要
2334`exception`は、リフレクションのメタ関数がエラーを報告するために送出する例外クラスである。[`std::exception`](/reference/exception/exception.md)から派生する。
2435
25- 定数評価中にのみ送出・捕捉されるため、実行時のオーバーヘッドはない。
36+ 定数評価中にのみ送出・捕捉されるため、実行時のオーバーヘッドはない。consteval-only型であり、実行時には存在できない。
2637
2738## メンバ関数
2839
2940| 名前 | 説明 |
3041|------|------|
42+ | `(constructor)` | `u8string_view`または`string_view`のメッセージ、送出元のリフレクション、ソース位置からオブジェクトを構築する |
3143| `what()` | エラーメッセージを通常のエンコーディングで取得 |
32- | `u8what()` | エラーメッセージをUTF-8で取得 |
44+ | `u8what()` | エラーメッセージをUTF-8([`u8string_view`](/reference/string_view/basic_string_view.md))で取得 |
3345| `from()` | 送出元のメタ関数のリフレクションを取得 |
3446| `where()` | エラーが発生したソース位置を取得 |
3547
@@ -51,3 +63,4 @@ namespace std::meta {
5163
5264## 参照
5365- [P3560R2 Error Handling in Reflection](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3560r2.html)
66+ - [LWG Issue 4513. `meta::exception::what()` should be `consteval`](https://cplusplus.github.io/LWG/issue4513)
0 commit comments