#include #include #include #include #include #include using namespace std; //----------------------------------------------- // A range for simplifies the code //----------------------------------------------- template void dumpContainer(const T c) { for (const auto &el : c) { cout << el << ' '; } cout << endl; } // It (sometimes) works for arrays as well (see end of main()), // but doesn't work here //void dumpNativeArray(int a[]) { // for (auto el : a ) { // cout << el << ' '; // } // cout << endl; //} //------------------------------------------------------- int main(int argc, char *argv[]) { string str = "one two three"; vector stringVec = {"one", "two", "three"}; deque intDeque = {1, 2, 3}; list floatList = {1.0, 2.0, 3.0}; forward_list doubleForwardList = {1.0, 2.0, 3.0}; int nativeArray[3] = {1, 2, 3}; dumpContainer(str); dumpContainer(stringVec); dumpContainer(intDeque); dumpContainer(floatList); dumpContainer(doubleForwardList); //dumpNativeArray(nativeArray); // The range for can sometimes work with native arrays, as well... for ( const auto & el : nativeArray ) { cout << el << ' '; } cout << endl; return 0; }