#include #include #include #include "counting_iterator.hpp" #include "tuple_element.hpp" void counting_iterator(){ std::vector v{1,3,37,1337,7}; for(auto x : counted(v)){ std::cout << "v[" << x.index << "] = " << x.value << std::endl; } for(auto x : counted(v)){ x.value *= x.index; } for(auto x : counted(v)){ std::cout << "v[" << x.index << "] = " << x.value << std::endl; } } void tuple_element (){ std::map m1; for(int i = -5; i <= 5; ++i) m1[i] = i*i; for(auto & p : values(m1)){ p -= 5; } auto const & m = m1; for(auto & p : values(m)){ // p is a const ref std::cout << p << "\t"; } std::cout << std::endl; for(auto & p : keys(m1)){ // p is a const ref, because keys in a map are const std::cout << p << "\t"; } std::cout << std::endl; } int main(){ counting_iterator(); tuple_element(); }