When debugging this under MSVC 2022 v143 with SDK 10.0.19041.0, I see that during the construction of exception_t m_format_args has an appropriate value, but at the time of calling what(), m_format_args has an invalid value. Most likely this is a lifetime issue, but I cannot see what is going wrong. (Most often this program does not print 42)
What am I doing wrong here?
int main() try { throw exception_t("{}", 42); } catch (std::exception& e) { std::println("{}", e.what()); } [/code] When debugging this under MSVC 2022 v143 with SDK 10.0.19041.0, I see that during the construction of exception_t m_format_args has an appropriate value, but at the time of calling what(), m_format_args has an invalid value. Most likely this is a lifetime issue, but I cannot see what is going wrong. (Most often this program does not print 42) What am I doing wrong here?
Это работает так, что я могу передать объект любого класса, у которого есть метод std::string format(), в std::format():
template
requires requires (T v) {
{ v.format() } -> std::convertible_to;
}
struct std::formatter : formatter
{
auto format(T...
Это работает так, что я могу передать объект любого класса, у которого есть метод std::string format(), в std::format():
template
requires requires (T v) {
{ v.format() } -> std::convertible_to;
}
struct std::formatter : formatter
{
auto format(T...
Это работает так, что я могу передать объект любого класса, у которого есть метод std::string format(), в std::format():
template
requires requires (T v) {
{ v.format() } -> std::convertible_to;
}
struct std::formatter : formatter
{
auto format(T...