Can I cause a compile error on “too few initializers”?
问题 I am using an aggregate initializer to set up a block of static data for a unit test. I would like to use the array size as the expected number of elements, but this can fail if too few initializers are provided: my_struct_type expected[14] = { { 1.234, 0, 'c' }, { 3.141, 1, 'z' }, { 2.718, 0, 'a' } }; This gives no compiler error in Visual Studio 2008. I would like to be able to use it as such: const unsigned expected_size = sizeof(expected) / sizeof(my_struct_type); BOOST_CHECK_EQUAL(points