Original Post
i'm hoping this is the proper place for this thread. after seeing boolean's thread the other day on "worst hello world" i decided to use that idea to become more familiar with stl. in this example, i was looking for a solution to using for_each without having to declare the data type of the contents of the container. the only thing i could get to work is this structure. i was wondering if this is only or proper way to do this.
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
struct f{
template<typename T>
void operator()(T&t){std::cout<<static_cast<char>(t);}
};
int main() {
std::string s("Hello World!");
std::vector<int>v(s.begin(),s.end());
for_each(v.begin(),v.end(),f());
return 0;
}