2009-08-01から1ヶ月間の記事一覧

もはやBoost.ScopeExit・・・

C++

#include <iostream> #include <boost/typeof/typeof.hpp> #include <boost/preprocessor/seq/cat.hpp> #include <boost/preprocessor/seq/for_each_i.hpp> // Steven Watanabe's trick namespace closure { namespace args { template<int> struct declare; typedef void* declared; struct undeclared { declared dummy[2…</int></boost/preprocessor/seq/for_each_i.hpp></boost/preprocessor/seq/cat.hpp></boost/typeof/typeof.hpp></iostream>

boost::filesystemを使ってある拡張子のファイルの先頭行に文字列を

C++

ちょっと必要になったので書いてみただけです。>< #include <iostream> #include <string> #include <boost/filesystem.hpp> #include <boost/filesystem/fstream.hpp> #include <boost/xpressive/xpressive.hpp> void replace_file( const boost::filesystem::path& dir, const std::string& inset_str) { try { namespace fs = boost::filesyste…</boost/xpressive/xpressive.hpp></boost/filesystem/fstream.hpp></boost/filesystem.hpp></string></iostream>

ちょっとだけクロージャを作ってみるのメモ

C++

#include <iostream> #include <vector> #define CLOSURE_(A0) CLOSURE_DEF(##A0, __LINE__) #define CLOSURE_DEF(A0, id) CLOSURE_IMPL(A0, id) #define CLOSURE_IMPL(A0, id)\ struct Closure_##id {\ typedef decltype(A0) Arg0;\ Arg0& A0;\ Closure_##id(Arg0& a0) : A0(a</vector></iostream>…