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

C++/Boost 小ネタ

コードだけ貼って全く説明しないのもアレかと思うので、汎用性のある手法をいくつか抜き出してみました。 boost::thread_specific_ptr Boost 版 TLS (Thread Local Storage)。thread_local がサポートされていない、でも __declspec(thread) や __thread は…

Boost.Context による単純なファイバー

いわゆる非対称コルーチン。C++03/11 両対応。 https://gist.github.com/3684731 簡単な使い方。 #include <iorate/fiber.hpp> int main() { iorate::fiber f([] { for (auto const c : "Hello, world!\n") { std::cout << c; iorate::fiber::yield(); } }); while (f.alive())</iorate/fiber.hpp>…