std::format_error(3)
π NAME π
std::format_error β std::format_error
okay so welcome to the C++ Standard Libary manual page for std::format_error(3), bestie π
. Yes, that's literally the name twice; the vibes are immaculate and the facts are the facts.
β¨ Synopsis β¨
Defined in header <format>.
class format_error; (since C++20)
So std::format_error defines the type of exception object thrown to report errors in the formatting library. It's giving "formatting went wrong, and we have thoughts" energy π.
The inheritance diagram asset is named std-format error-inheritance.svg, and its caption is Inheritance diagram.
π Member functions π
- constructor β constructs a new
format_errorobject with the given message (public member function). - operator= β replaces the
format_errorobject (public member function).
π
std::format_error::format_error
okay bestie, here are the three constructor flavors, all cute and accounted for:
format_error( const std::string& what_arg ); (1)
format_error( const char* what_arg ); (2)
format_error( const format_error& other ) noexcept; (3)
- Constructs the exception object with
what_argas explanatory string. After construction,std::strcmp(what(), what_arg.c_str()) == 0. - Constructs the exception object with
what_argas explanatory string. After construction,std::strcmp(what(), what_arg) == 0. - Copy constructor. If
*thisandotherboth have dynamic typestd::format_errorthenstd::strcmp(what(), other.what()) == 0. No exception can be thrown from the copy constructor.
πΈ Parameters πΈ
what_argβ explanatory string.otherβ another exception object to copy.
π₯ Exceptions π₯
1,2)β May throwstd::bad_alloc.
π Notes π
Because copying std::format_error is not permitted to throw exceptions, this message is typically stored internally as a separately-allocated reference-counted string. This is also why there is no constructor taking std::string&&: it would have to copy the content anyway.
A derived standard exception class must have a publicly accessible copy constructor. It can be implicitly defined as long as the explanatory strings obtained by what() are the same for the original object and the copied object.
π¦ std::format_error::operator=
format_error& operator=( const format_error& other ) noexcept;
Assigns the contents with those of other. If *this and other both have dynamic type std::format_error then std::strcmp(what(), other.what()) == 0 after assignment. No exception can be thrown from the copy assignment operator.
π Parameters π
otherβ another exception object to assign with.
β Return value β
*this
π Notes π
A derived standard exception class must have a publicly accessible copy assignment operator. It can be implicitly defined as long as the explanatory strings obtained by what() are the same for the original object and the copied object.
π Inherited from std::runtime_error
yep β inherited from std::runtime_error, bestie. That's the base-class pipeline π
.
π Inherited from std::exception
π Member functions π
- destructor β destroys the exception object;
[virtual](virtual public member function ofstd::exception). - what β returns an explanatory string;
[virtual](virtual public member function ofstd::exception).
π Example π
This section is incomplete.
Reason: no example.
π See also π
ποΈ Category:
- Todo no example
That's the whole page, bestie π«Ά β source http://cppreference.com, version/date 2024.06.10, manual page std::format_error(3). Bye π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms