Doc/syntax work.
[libsex.git] / source / utility.ixx
blobd53b5cf15c9250ea6fd8e12e3faf66ef5eb789ad
1 #include <source/Exception.hxx> // Exception::LENGTH
3 template <typename T>
4 T libsex::formatted(
5         const char* const file,
6         unsigned short line,
7         ...) throw()
9         // Temporary string should be initialized
10         // with 0 to not forget a trailing 0.
11         char buf[Exception::LENGTH + 1] = { 0 };
13         va_list ap;
14         va_start(ap, line);
16         // Fill buf with formatted T::TEMPLATE message.
17         vformat(buf, Exception::LENGTH + 1,
18                 file, line,
19                 T::TEMPLATE, ap);\
20         va_end(ap);
22         return T(buf);
25 template <typename T>
26 T libsex::formatted(
27         const Exception& previous,
28         const char* const file,
29         unsigned short line,
30         ...) throw()
32         char buf[Exception::LENGTH + 1] = { 0 };
34         va_list ap;
35         va_start(ap, line);
36         vformat(buf, Exception::LENGTH + 1,
37                 file, line,
38                 T::TEMPLATE, ap);\
39         va_end(ap);
41         return T(buf, previous);