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

C++0xのラムダ式でクロージャ

C++

#include <iostream> #include <functional> #include <string> int main() { auto f = [](std::string &&str) -> std::function<void()> { std::string s_ = str; return [s_] () mutable -> void { std::cout << s_ << std::endl; s_ += std::string(" Hello"); }; }; auto g = f("Message : "); </void()></string></functional></iostream>…

ちょっと乗り遅れな気がするけどSleep-Sort(C++0x, Boost, PStade.Oven)

#include <iostream> #include <vector> #include <boost/thread.hpp> #include <pstade/oven/algorithm.hpp> int main() { std::vector<int> v = {4, 2, 6, 1, 9, 10, 3, 7}; boost::thread_group ths; pstade::oven::for_each( v, [&ths](int n) { ths.add_thread( new boost::thread( [](int n) { boost::this_thread::s…</int></pstade/oven/algorithm.hpp></boost/thread.hpp></vector></iostream>

scoped enum

C++

enum_typeと名前をつけたenumを内部にもつstructを渡すだけでscoped_enumにする。0xが欲しいけど使えない人のため。 // Copyright hotwatermorning 2011. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE…

Boost.Rangeのirangeのstepに対してOvenのsteps

http://homepage1.nifty.com/herumi/diary/1105.html#13 Ovenは意図通りの挙動だった。 (というよりOvenには同様の機能が無いのでstepsを使った。) boost1.46.1 Ovenはtrunk(たぶん現行のリリースの1.04.3でも問題ない) #include <iostream> #include <pstade/oven/algorithm.hpp> #include <pstade/oven/counting.hpp> #incl</pstade/oven/counting.hpp></pstade/oven/algorithm.hpp></iostream>…

Thunderbirdでニュースグループの表示名を省略しない。

Technology Reviews & Software Reviews From Fixunix日本語では中々欲しい情報が無かった。(表示名が省略されるけど空気を読んで解釈するみたいな事を書いてるとこもあるし)。 情報量が桁違いですから、英語を読める程度の能力の必要性を感じますですなぁ…