#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { vector<int> v; v.push_back(3); v.push_back(1); v.push_back(4); sort(v.begin(), v.end()); for (vector<int>::iterator it = v.begin(); it != v.end(); ++it) cout << *it << endl; return 0; }
私が主にBoostをマネて作ったライブラリを使って書いたソース
#include <iostream> #include <shand/foreach.hpp> #include <shand/algorithm.hpp> #include <shand/assign/vector.hpp> using namespace std; using namespace shand; using namespace shand::assign; int main() { vector<int> v; v += 3, 1, 4; sort(v); foreach (int value, v) cout << value << endl; return 0; }
C++0xで書いたソース
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { vector<int> v = {3, 1, 4}; sort(v); for (int value : v) cout << value << endl; return 0; }
けっこう0xに近づけた気がする