Skip to content

Commit d5f8cb1

Browse files
committed
P3560R2 Error Handling in Reflection
1 parent 178a7f4 commit d5f8cb1

File tree

2 files changed

+133
-0
lines changed

2 files changed

+133
-0
lines changed

source/meta.tex

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2582,6 +2582,9 @@
25822582
namespace std::meta {
25832583
using info = decltype(^^::);
25842584

2585+
// \ref{meta.reflection.exception}, class \tcode{exception}
2586+
class exception;
2587+
25852588
// \ref{meta.reflection.operators}, operator representations
25862589
enum class operators {
25872590
@\seebelow@;
@@ -2968,6 +2971,135 @@
29682971
\end{codeblock}
29692972
\end{example}
29702973

2974+
\rSec2[meta.reflection.exception]{Class \tcode{exception}}
2975+
2976+
\indexlibraryglobal{exception}%
2977+
\begin{itemdecl}
2978+
class exception : public std::exception
2979+
{
2980+
private:
2981+
optional<string> @\exposid{what_}@; // \expos
2982+
u8string @\exposid{u8what_}@; // \expos
2983+
info @\exposid{from_}@; // \expos
2984+
source_location @\exposid{where_}@; // \expos
2985+
2986+
public:
2987+
consteval exception(u8string_view what, info from,
2988+
source_location where = source_location::current()) noexcept;
2989+
2990+
consteval exception(string_view what, info from,
2991+
source_location where = source_location::current()) noexcept;
2992+
2993+
exception(const exception&) = default;
2994+
exception(exception&&) = default;
2995+
2996+
exception& operator=(const exception&) = default;
2997+
exception& operator=(exception&&) = default;
2998+
2999+
constexpr const char* what() const noexcept override;
3000+
consteval u8string_view u8what() const noexcept;
3001+
consteval info from() const noexcept;
3002+
consteval source_location where() const noexcept;
3003+
};
3004+
\end{itemdecl}
3005+
3006+
\begin{itemdescr}
3007+
\pnum
3008+
Reflection functions throw exceptions of type \tcode{meta::exception}
3009+
to signal an error.
3010+
\tcode{meta::exception} is a consteval-only type.
3011+
\end{itemdescr}
3012+
3013+
\indexlibraryctor{exception}%
3014+
\begin{itemdecl}
3015+
consteval exception(u8string_view what, info from,
3016+
source_location where = source_location::current()) noexcept;
3017+
\end{itemdecl}
3018+
3019+
\begin{itemdescr}
3020+
\pnum
3021+
\effects
3022+
Initializes
3023+
\exposid{u8what_} with \tcode{what},
3024+
\exposid{from_} with \tcode{from}, and
3025+
\exposid{where_} with \tcode{where}.
3026+
If \tcode{what} can be represented in the ordinary literal encoding,
3027+
initializes \exposid{what_} with \tcode{what},
3028+
transcoded from UTF-8 to the ordinary literal encoding.
3029+
Otherwhise, \exposid{what_} is value-initialized.
3030+
\end{itemdescr}
3031+
3032+
\indexlibraryctor{exception}%
3033+
\begin{itemdecl}
3034+
consteval exception(string_view what, info from,
3035+
source_location where = source_location::current()) noexcept;
3036+
\end{itemdecl}
3037+
3038+
\begin{itemdescr}
3039+
\pnum
3040+
\constantwhen
3041+
\tcode{what} designates a sequence of characters
3042+
that can be encoded in UTF-8.
3043+
3044+
\pnum
3045+
\effects
3046+
Initializes
3047+
\exposid{what_} with \tcode{what},
3048+
\exposid{u8what_} with \tcode{what}
3049+
transcoded from the ordinary literal encoding to UTF-8,
3050+
%FIXME: Oxford comma before "and"
3051+
\exposid{from_} with \tcode{from} and
3052+
\exposid{where_} with \tcode{where}.
3053+
\end{itemdescr}
3054+
3055+
\indexlibrarymember{what}{exception}%
3056+
\begin{itemdecl}
3057+
constexpr const char* what() const noexcept override;
3058+
\end{itemdecl}
3059+
3060+
\begin{itemdescr}
3061+
\pnum
3062+
\constantwhen
3063+
\tcode{\exposid{what_}.has_value()} is \tcode{true}.
3064+
3065+
\pnum
3066+
\returns
3067+
\tcode{\exposid{what_}->c_str()}.
3068+
\end{itemdescr}
3069+
3070+
\indexlibrarymember{u8what}{exception}%
3071+
\begin{itemdecl}
3072+
consteval u8string_view what() const noexcept;
3073+
\end{itemdecl}
3074+
3075+
\begin{itemdescr}
3076+
\pnum
3077+
\returns
3078+
\exposid{u8what_}.
3079+
\end{itemdescr}
3080+
3081+
\indexlibrarymember{from}{exception}%
3082+
\begin{itemdecl}
3083+
consteval info from() const noexcept;
3084+
\end{itemdecl}
3085+
3086+
\begin{itemdescr}
3087+
\pnum
3088+
\returns
3089+
\exposid{from_}.
3090+
\end{itemdescr}
3091+
3092+
\indexlibrarymember{where}{exception}%
3093+
\begin{itemdecl}
3094+
consteval source_location where() const noexcept;
3095+
\end{itemdecl}
3096+
3097+
\begin{itemdescr}
3098+
\pnum
3099+
\returns
3100+
\exposid{where_}.
3101+
\end{itemdescr}
3102+
29713103
\rSec2[meta.reflection.operators]{Operator representations}
29723104

29733105
\begin{itemdecl}

source/support.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,7 @@
791791
#define @\defnlibxname{cpp_lib_rcu}@ 202306L // also in \libheader{rcu}
792792
#define @\defnlibxname{cpp_lib_reference_from_temporary}@ 202202L // freestanding, also in \libheader{type_traits}
793793
#define @\defnlibxname{cpp_lib_reference_wrapper}@ 202403L // freestanding, also in \libheader{functional}
794+
#define @\defnlibxname{cpp_lib_reflection}@ 202506L // also in \libheader{meta}
794795
#define @\defnlibxname{cpp_lib_remove_cvref}@ 201711L // freestanding, also in \libheader{type_traits}
795796
#define @\defnlibxname{cpp_lib_result_of_sfinae}@ 201210L
796797
// freestanding, also in \libheader{functional}, \libheader{type_traits}

0 commit comments

Comments
 (0)