2009-02-09から1日間の記事一覧

Boost.ScopeExit使ってみた

C++

ScopeExitはスコープを抜けたときに実行されるブロックを定義できます。 C++0xのラムダ式風に変数をキャプチャすることができます。 #include <iterator> #include <iostream> #include <vector> #include <algorithm> #include <boost/scope_exit.hpp> using namespace std; vector<int> v; void foo() { int index = 1; v.push</int></boost/scope_exit.hpp></algorithm></vector></iostream></iterator>…

shared_ptrのコンストラクタにDerivedFrom

C++

shared_ptrのコンストラクタはN2800では以下のようになってますが template <class T> class shared_ptr { public: template <class Y> explicit shared_ptr(Y* p); }; YはDerivedFromコンセプトで制約しておいたほうがいいんじゃないかな template <class T> class shared_ptr { public</class></class></class>…