I have this code:
// initializer lists
#include <iostream>
#include <vector>
int main()
{
int values[] { 1, 2, 3 };
std::vector<int> v { 4, 5, 6 };
std::vector<std::string> cities {
"London", "New York", "Paris", "Tokio"
};
return 0;
}
However the gcc
compiler gives me unused variable
warning only for values
array. Why v
and cities
is not reported?
It is not a primitive value, so its constructor and/or destructor might have desired side effects.
Classical example: a Timer object which measures the time between its construction and destruction: https://stackoverflow.com/a/5302868/1938163