Skip to content

Commit 567409d

Browse files
committed
P3560R2 Error Handling in Reflection
1 parent f9b848c commit 567409d

File tree

1 file changed

+132
-0
lines changed

1 file changed

+132
-0
lines changed

source/meta.tex

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2599,6 +2599,9 @@
25992599
namespace std::meta {
26002600
using info = decltype(^^::);
26012601

2602+
// \ref{meta.reflection.exception}, class \tcode{exception}
2603+
class exception;
2604+
26022605
// \ref{meta.reflection.operators}, operator representations
26032606
enum class operators {
26042607
@\seebelow@;
@@ -3102,6 +3105,135 @@
31023105
\end{note}
31033106
\end{itemdescr}
31043107

3108+
\rSec2[meta.reflection.exception]{Class \tcode{exception}}
3109+
3110+
\indexlibraryglobal{exception}%
3111+
\begin{itemdecl}
3112+
class exception : public std::exception
3113+
{
3114+
private:
3115+
optional<string> @\exposid{what_}@; // \expos
3116+
u8string @\exposid{u8what_}@; // \expos
3117+
info @\exposid{from_}@; // \expos
3118+
source_location @\exposid{where_}@; // \expos
3119+
3120+
public:
3121+
consteval exception(u8string_view what, info from,
3122+
source_location where = source_location::current()) noexcept;
3123+
3124+
consteval exception(string_view what, info from,
3125+
source_location where = source_location::current()) noexcept;
3126+
3127+
exception(const exception&) = default;
3128+
exception(exception&&) = default;
3129+
3130+
exception& operator=(const exception&) = default;
3131+
exception& operator=(exception&&) = default;
3132+
3133+
constexpr const char* what() const noexcept override;
3134+
consteval u8string_view u8what() const noexcept;
3135+
consteval info from() const noexcept;
3136+
consteval source_location where() const noexcept;
3137+
};
3138+
\end{itemdecl}
3139+
3140+
\begin{itemdescr}
3141+
\pnum
3142+
Reflection functions throw exceptions of type \tcode{meta::exception}
3143+
to signal an error.
3144+
\tcode{meta::exception} is a consteval-only type.
3145+
\end{itemdescr}
3146+
3147+
\indexlibraryctor{exception}%
3148+
\begin{itemdecl}
3149+
consteval exception(u8string_view what, info from,
3150+
source_location where = source_location::current()) noexcept;
3151+
\end{itemdecl}
3152+
3153+
\begin{itemdescr}
3154+
\pnum
3155+
\effects
3156+
Initializes
3157+
\exposid{u8what_} with \tcode{what},
3158+
\exposid{from_} with \tcode{from}, and
3159+
\exposid{where_} with \tcode{where}.
3160+
If \tcode{what} can be represented in the ordinary literal encoding,
3161+
initializes \exposid{what_} with \tcode{what},
3162+
transcoded from UTF-8 to the ordinary literal encoding.
3163+
Otherwhise, \exposid{what_} is value-initialized.
3164+
\end{itemdescr}
3165+
3166+
\indexlibraryctor{exception}%
3167+
\begin{itemdecl}
3168+
consteval exception(string_view what, info from,
3169+
source_location where = source_location::current()) noexcept;
3170+
\end{itemdecl}
3171+
3172+
\begin{itemdescr}
3173+
\pnum
3174+
\constantwhen
3175+
\tcode{what} designates a sequence of characters
3176+
that can be encoded in UTF-8.
3177+
3178+
\pnum
3179+
\effects
3180+
Initializes
3181+
\exposid{what_} with \tcode{what},
3182+
\exposid{u8what_} with \tcode{what}
3183+
transcoded from the ordinary literal encoding to UTF-8,
3184+
%FIXME: Oxford comma before "and"
3185+
\exposid{from_} with \tcode{from} and
3186+
\exposid{where_} with \tcode{where}.
3187+
\end{itemdescr}
3188+
3189+
\indexlibrarymember{what}{exception}%
3190+
\begin{itemdecl}
3191+
constexpr const char* what() const noexcept override;
3192+
\end{itemdecl}
3193+
3194+
\begin{itemdescr}
3195+
\pnum
3196+
\constantwhen
3197+
\tcode{\exposid{what_}.has_value()} is \tcode{true}.
3198+
3199+
\pnum
3200+
\returns
3201+
\tcode{\exposid{what_}->c_str()}.
3202+
\end{itemdescr}
3203+
3204+
\indexlibrarymember{u8what}{exception}%
3205+
\begin{itemdecl}
3206+
consteval u8string_view what() const noexcept;
3207+
\end{itemdecl}
3208+
3209+
\begin{itemdescr}
3210+
\pnum
3211+
\returns
3212+
\exposid{u8what_}.
3213+
\end{itemdescr}
3214+
3215+
\indexlibrarymember{from}{exception}%
3216+
\begin{itemdecl}
3217+
consteval info from() const noexcept;
3218+
\end{itemdecl}
3219+
3220+
\begin{itemdescr}
3221+
\pnum
3222+
\returns
3223+
\exposid{from_}.
3224+
\end{itemdescr}
3225+
3226+
\indexlibrarymember{where}{exception}%
3227+
\begin{itemdecl}
3228+
consteval source_location where() const noexcept;
3229+
\end{itemdecl}
3230+
3231+
\begin{itemdescr}
3232+
\pnum
3233+
\returns
3234+
\exposid{where_}.
3235+
\end{itemdescr}
3236+
31053237
\rSec2[meta.reflection.operators]{Operator representations}
31063238

31073239
\begin{itemdecl}

0 commit comments

Comments
 (0)