diff --git a/format.ipp b/format.ipp index 042502b9..1b378b13 100644 --- a/format.ipp +++ b/format.ipp @@ -28,6 +28,41 @@ namespace util { namespace detail { namespace format { + /////////////////////////////////////////////////////////////////////// + template + inline bool + is_valid_specifier (const char*) + { return false; } + + + //--------------------------------------------------------------------- + template <> + inline bool + is_valid_specifier (const char *s) + { return *s == 's'; } + + //--------------------------------------------------------------------- + template <> + inline bool + is_valid_specifier (const char *s) + { return *s == 's'; } + + + //--------------------------------------------------------------------- + template <> + inline bool + is_valid_specifier (const char *s) + { return *s == 's'; } + + + //--------------------------------------------------------------------- + template <> + inline bool + is_valid_specifier (const char *s) + { return *s == 'u'; } + + + /////////////////////////////////////////////////////////////////////// template void render (InputIt first, @@ -42,6 +77,7 @@ namespace util { } + //--------------------------------------------------------------------- template @@ -65,8 +101,8 @@ namespace util { if (spec == last) throw util::format::format_error ("missing format specifier"); - if (*spec != 's') - throw util::format::format_error ("unhandled format specifier"); + if (!is_valid_specifier::type> (&*spec)) + throw util::format::format_error ("invalid/unhandled format specifier"); dest << val; @@ -74,6 +110,7 @@ namespace util { } } } + /////////////////////////////////////////////////////////////////////////// namespace format { template std::string