Improved doc and syntax.
[libsex.git] / include / libsex / utility.ixx
blob489d8cc86a60f93f8accf74f1f509cb56e53bb88
1 #include <libsex/Exception.hxx> // Exception::LENGTH
3 namespace libsex {
5 template <typename T>
6 T formatted(
7         const char* const file,
8         unsigned short line,
9         ...) throw()
11         // Temporary string should be initialized
12         // with 0 to not forget a trailing 0.
13         char buf[Exception::LENGTH + 1] = { 0 };
15         va_list ap;
16         va_start(ap, line);
17         // Fill buf with formatted T::TEMPLATE message.
18         vformat(
19                 buf, Exception::LENGTH + 1,
20                 file, line,
21                 T::TEMPLATE, ap);\
22         va_end(ap);
24         return T(buf);
27 }; // End of namespace.