10#include "source_location.hpp"
12#include "concepts.hpp"
41 using value_type = ValueType;
43 std::optional<value_type> value;
51 return fmt::format(
"{}={}", Tag, to_string(*value));
53 return fmt::format(
"{}={}", Tag, *value);
90 tt_axiom(state == state::closed);
93 state = state::writing;
94 set<
"source_location">(location);
106 tt_axiom(reopen ==
true);
107 if (state == state::closed) {
113 tt_axiom(state == state::reading);
118 state = state::writing;
123 tt_axiom(state == state::writing);
126 state = state::reading;
129 error_info(error_info &&rhs)
noexcept =
delete;
130 error_info &operator=(error_info &&rhs)
noexcept =
delete;
131 error_info(error_info
const &rhs) =
delete;
132 error_info &operator=(error_info
const &rhs) =
delete;
143 template<basic_fixed_
string Tag,
typename Arg>
146 tt_axiom(state == state::writing);
149 auto &e = entry<Tag, std::remove_cvref_t<Arg>>;
150 if (e.version == 0) {
153 [[unlikely]] register_entry(e);
157 e.value = std::forward<Arg>(value);
169 tt_axiom(state == state::closed || state == state::reading);
171 state = state::closed;
184 template<
typename ValueType, basic_fixed_
string Tag>
185 static std::optional<ValueType>
pop() noexcept
188 tt_axiom(state == state::closed);
190 auto &e = entry<Tag,ValueType>;
192 return std::exchange(e.value, {});
206 template<
typename ValueType, basic_fixed_
string Tag>
207 static std::optional<ValueType>
peek() noexcept
209 auto &e = entry<Tag,ValueType>;
223 for (
auto e: entries) {
244 inline static thread_local uint64_t version;
248 inline static thread_local state state;
252 template<basic_fixed_
string Tag,
typename ValueType>
253 inline static thread_local detail::error_info_entry<Tag, ValueType> entry;
260 tt_no_inline
static void register_entry(detail::error_info_entry_base &e)
noexcept
279#define tt_error_info() tt::error_info(tt_source_location_current())
Definition error_info.hpp:31
virtual std::string string() noexcept=0
Get a string representation of the tag and value of this entry.
Definition error_info.hpp:40
std::string string() noexcept override
Get a string representation of the tag and value of this entry.
Definition error_info.hpp:45
Error information passed alongside an error code or exception.
Definition error_info.hpp:81
error_info(source_location location) noexcept
Open an error info transaction.
Definition error_info.hpp:87
static void close() noexcept
Close the current transaction.
Definition error_info.hpp:167
static std::optional< ValueType > peek() noexcept
Non-destructive read data from the current transaction.
Definition error_info.hpp:207
static std::optional< ValueType > pop() noexcept
Destructive read data from the current transaction.
Definition error_info.hpp:185
error_info & set(Arg &&value) noexcept
Set an information for a given tag.
Definition error_info.hpp:144
error_info(bool reopen) noexcept
Reopen a error info transaction.
Definition error_info.hpp:104
static std::string string() noexcept
Return the list of entries with their current set value.
Definition error_info.hpp:219
example: ``` template<tt::basic_fixed_string Foo> class A { auto bar() { return std::string{Foo}; } }...
Definition fixed_string.hpp:29
Definition source_location.hpp:10
Definition version.hpp:11
Definition concepts.hpp:51