14template<
typename... More>
16 using Tuple = std::tuple<More...>;
18 LastErrorBase()
noexcept {}
22 std::tuple_element_t<idx, Tuple> &
get() noexcept {
23 return std::get<idx>(m_members);
28 const std::tuple_element_t<idx, Tuple> &
get() const noexcept {
29 return std::get<idx>(m_members);
33 template<
size_t idx,
typename Arg>
34 void set(Arg &&val)
noexcept {
35 std::get<idx>(m_members) = std::forward<Arg>(val);
40 std::apply([](
auto &... args) { ((args = {}), ...); }, m_members);
51template<
typename... More>
67 requires (std::is_convertible_v<T, std::string_view>) {
68 m_lastError = std::forward<T>(str);
75 const std::string &
lastError() const & noexcept {
return m_lastError; }
78 std::string m_lastError;
86template<
typename... More>
112 std::string
lastError() const noexcept {
return m_lastError.str(); }
115 std::ostringstream m_lastError;
void resetMembers() noexcept
Wipe out members.
Definition LastError.h:39
void set(Arg &&val) noexcept
Set n-th error member.
Definition LastError.h:34
std::tuple_element_t< idx, Tuple > & get() noexcept
Get n-th error member.
Definition LastError.h:22
const std::tuple_element_t< idx, Tuple > & get() const noexcept
Get n-th error member.
Definition LastError.h:28
Stores a string (usually an error string) to be retrieved later.
Definition LastError.h:52
const std::string & lastError() const &noexcept
Obtain the stored string.
Definition LastError.h:75
void setError(T &&str)
Store a string into this error.
Definition LastError.h:66
LastErrorStr & reset() noexcept
Wipe out everything.
Definition LastError.h:55
Stores a string (usually an error string) to be retrieved later.
Definition LastError.h:87
std::string lastError() const noexcept
Obtain the stored string.
Definition LastError.h:112
LastErrorStream & reset() noexcept
Wipe out everything.
Definition LastError.h:90
LastErrorStream & operator<<(const T &x)
Store something into this error.
Definition LastError.h:103