Check for argument indexing switch

This commit is contained in:
Victor Zverovich 2017-09-27 21:18:37 -07:00
parent d45544d14e
commit 643fb0662e
2 changed files with 5 additions and 0 deletions

View File

@ -3296,6 +3296,7 @@ class dynamic_specs_handler :
template <typename Id>
arg_ref_type make_arg_ref(Id arg_id) {
context_.check_arg_id(arg_id);
return arg_ref_type(arg_id);
}

View File

@ -1562,6 +1562,10 @@ TEST(FormatTest, DynamicFormatter) {
EXPECT_EQ("42", format("{:d}", num));
EXPECT_EQ("foo", format("{:s}", str));
EXPECT_EQ(" 42 foo ", format("{:{}} {:{}}", num, 3, str, 4));
EXPECT_THROW_MSG(format("{0:{}}", num),
format_error, "cannot switch from manual to automatic argument indexing");
EXPECT_THROW_MSG(format("{:{0}}", num),
format_error, "cannot switch from automatic to manual argument indexing");
EXPECT_THROW_MSG(format("{:=}", str),
format_error, "format specifier '=' requires numeric argument");
EXPECT_THROW_MSG(format("{:+}", str),