2011-06-01から1ヶ月間の記事一覧

range-based for

gcc 4.6.1をビルドしたので動作確認。 #include <iostream> #include <list> #include <memory> struct Task{ int id; Task(int id) : id(id){ std::cout << "Create Task : " << id << std::endl; } ~Task(){ std::cout << "Delete Task : " << id << std::endl; } void update(){ s</memory></list></iostream>…

ムーブセマンティクス(Move Semantics)はテクニックにすぎない

正確には、C++0xではムーブセマンティクスを実現"しやすく"なっただけで、 ムーブ自体は昔からのテクニックに過ぎない。 という事をやっと理解したっぽい?メモ。 #include <iostream> #include <vector> #include <string> std::vector<std::string> add_bar(std::vector<std::string> lhs) { lhs.push_back("bar</std::string></std::string></string></vector></iostream>…