Fix: Headers are now installed.
[libsex.git] / include / libsex / utility.ixx
blobd75aac189d96fb05b548411b07561cd6eeec2d75
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);
18         // Fill buf with formatted T::TEMPLATE message.
19         vformat(buf, Exception::LENGTH + 1,
20                 file, line,
21                 T::TEMPLATE, ap);\
22         va_end(ap);
24         return T(buf);
27 template <typename T>
28 T formatted(
29         const Exception& previous,
30         const char* const file,
31         unsigned short line,
32         ...) throw()
34         char buf[Exception::LENGTH + 1] = { 0 };
36         va_list ap;
37         va_start(ap, line);
38         vformat(buf, Exception::LENGTH + 1,
39                 file, line,
40                 T::TEMPLATE, ap);\
41         va_end(ap);
43         return T(buf, previous);
46 }; // End of namespace.