format: support string_view as a string

This commit is contained in:
Danny Robson 2019-04-16 10:18:10 +10:00
parent 71c44b3293
commit 520af37042

View File

@ -265,9 +265,13 @@ namespace cruft::format {
break; break;
case type_t::STRING: case type_t::STRING:
if (!std::is_same_v<ValueT, view<const char*>> && !std::is_same_v<ValueT, std::string>) if (std::is_same_v<ValueT, view<const char*>>)
throw std::runtime_error ("expected string value");
break; break;
if (std::is_same_v<ValueT, std::string>)
break;
if (std::is_same_v<ValueT, std::string_view>)
break;
throw std::runtime_error ("expected string value");
case type_t::POINTER: case type_t::POINTER:
if (!std::is_pointer_v<ValueT> && !std::is_integral_v<ValueT>) if (!std::is_pointer_v<ValueT> && !std::is_integral_v<ValueT>)