More compile-time checks

This commit is contained in:
Victor Zverovich
2017-11-05 13:18:42 -08:00
parent 1c855a4762
commit a03842b0d5
2 changed files with 24 additions and 18 deletions

View File

@@ -1234,8 +1234,11 @@ namespace fmt {
template <>
struct formatter<Date> {
template <typename ParseContext>
auto parse(ParseContext &ctx) -> decltype(ctx.begin()) {
return ctx.begin();
constexpr auto parse(ParseContext &ctx) -> decltype(ctx.begin()) {
auto it = ctx.begin();
if (*it == 'd')
++it;
return it;
}
void format(buffer &buf, const Date &d, context &) {
@@ -1813,8 +1816,7 @@ TEST(FormatTest, ConstexprParseFormatString) {
static_assert(parse_string("{:}"), "");
}
#if FMT_UDL_TEMPLATE
TEST(FormatTest, UdlTemplate) {
EXPECT_EQ("foo", "foo"_format());
EXPECT_EQ(" 42", "{0:10}"_format(42));
}
#endif