#include std::vector v(10, 1); // The innocent declaration above was intended to declare a vector of ten // ints initialized to one. But it results in the following error message: // // "include/iterator", line 188: error: no instance of overloaded // function "std::iterator_category" matches the argument list // argument types are: (int) // __distance (first, last, n, iterator_category(first)); // ^ // detected during: // instantiation of "void std::distance(int, int, // std::vector::size_type &)" at line 101 of // "/ldg37/c++/port04/inst.v30/include/vector" // instantiation of "std::vector::vector(int, int)" at line 3 of // "vector.C" // // 1 error detected in the compilation of "vector.C". // // The compiler and library are correct, the error is in the declaration. // Below is a correct declaration for a vector of ten ints initialized to one. // The difference is that the 10 now unsigned, which makes the intended // constructor a better match. std::vector w(10u, 1);