how can i pass an iterator to a template function and create local container that has same type as the iterator?
how can i pass an iterator to a template function and create local container that has same type as the iterator?
Simple:
Code:template < typename Iterator > void foo( Iterator begin, Iterator end ) { Iterator seq = begin; /* do something */ } // or when dealing with 'standard' containers: template < typename Container > void bar( Container const& data ) { typename Container::const_iterator seq = data.begin( ); /* do something */ }
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
I'm not quite sure what you're asking for. If I pass in a vector<int>::reverse_iterator, do you want to get hold of int, or vector<int>, or vector<int>::reverse_iterator?