diff --git a/tests/test_acceptor.cpp b/tests/test_acceptor.cpp index f12801a..96ceb7c 100644 --- a/tests/test_acceptor.cpp +++ b/tests/test_acceptor.cpp @@ -411,6 +411,14 @@ BOOST_AUTO_TEST_CASE(test_array) const std::string arr2("[#c\n1,\n2,#comment\r\n3]"); BOOST_CHECK(is_valid::invoke(arr2.cbegin()) == arr2.cend()); } + + { + const std::string invalid("[1, 3.14, 'string']"); + BOOST_CHECK(is_valid::invoke(invalid.cbegin()) == invalid.cbegin()); + const std::string valid("[[1,2,3], [3.14, 2.71, 1.414], ['foo', 'bar']]"); + BOOST_CHECK(is_valid::invoke(valid.cbegin()) == valid.cend()); + } + } BOOST_AUTO_TEST_CASE(test_inline_table) diff --git a/toml/acceptor.hpp b/toml/acceptor.hpp index 8104142..2873544 100644 --- a/toml/acceptor.hpp +++ b/toml/acceptor.hpp @@ -547,6 +547,34 @@ using is_key = is_literal_inline_string >; + +template +using is_fixed_type_array = + is_chain_of< + is_charactor, + is_ignorable< + is_repeat_of< + is_chain_of< + is_ignorable>, + is_array_component, + is_ignorable>, + is_charactor + >, + repeat_infinite() + > + >, + is_ignorable< + is_chain_of< + is_ignorable>, + is_array_component, + is_ignorable>, + is_ignorable> + > + >, + is_ignorable>, + is_charactor + >; + template struct is_array { @@ -557,34 +585,15 @@ struct is_array value_type>::value>::type> static Iterator invoke(Iterator iter) { - typedef is_one_of, - is_array, is_inline_table> is_component; - - typedef is_chain_of< - is_charactor, - is_ignorable< - is_repeat_of< - is_chain_of< - is_ignorable>, - is_component, - is_ignorable>, - is_charactor - >, - repeat_infinite() - > - >, - is_ignorable< - is_chain_of< - is_ignorable>, - is_component, - is_ignorable>, - is_ignorable> - > - >, - is_ignorable>, - is_charactor - > entity; - return entity::invoke(iter); + return is_one_of< + is_fixed_type_array>, + is_fixed_type_array>, + is_fixed_type_array>, + is_fixed_type_array>, + is_fixed_type_array>, + is_fixed_type_array>, + is_fixed_type_array> + >::invoke(iter); } };