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

Boost.GIL に手を付けてみた

まあすぐに飽きる気がするけど。 とりあえず、 Naming convention for GIL concrete types Concrete (non-generic) GIL types follow this naming convention: ColorSpace + BitDepth + [f | s]+ [c] + [_planar] + [_step] + ClassType + _t Where ColorSpa…

boost::mpl::push_back

#include <boost/mpl/push_back.hpp> #include <boost/mpl/push_front.hpp> #include <boost/mpl/list.hpp> using namespace boost::mpl; void main() { typedef list<int, char> list2; //typedef push_back<list2, void*>::type list3; // ↑コンパイルエラー typedef push_front<list2, void*>::type list3; // ↑こっちなら通る } 謎だ...。</list2,></list2,></int,></boost/mpl/list.hpp></boost/mpl/push_front.hpp></boost/mpl/push_back.hpp>

property_tree

何をやるクラスなのかまったく理解してないんだけど、 xml_parser_read_spirit.hpp ここの xml_grammar クラスだけ切り取ってゴニョゴニョしてみたい衝動に駆られた。 でもよく考えてみると XML って DTD とか XML Schema がないと無用の長物だよなぁとか思…

スレッドの同期呼び出し

を作ってみた。 #ifndef ANMELT_THREAD_INVOKE_H_INCLUDED #define ANMELT_THREAD_INVOKE_H_INCLUDED // Boost #include <boost/thread.hpp> #include <boost/optional.hpp> #include <boost/noncopyable.hpp> #include <boost/ref.hpp> #include <boost/utility/enable_if.hpp> #include <boost/utility/result_of.hpp> #include …</boost/utility/result_of.hpp></boost/utility/enable_if.hpp></boost/ref.hpp></boost/noncopyable.hpp></boost/optional.hpp></boost/thread.hpp>

スレッドプール

Worker Thread パターンでスレッドプールを作ってみた。 worker_thread.h #ifndef ANMELT_THREAD_WORKER_THREAD_H_INCLUDED #define ANMELT_THREAD_WORKER_THREAD_H_INCLUDED // Boost #include <boost/thread.hpp> #include <boost/shared_ptr.hpp> #include <boost/function.hpp> #include <boost/bind.hpp> #include </boost/bind.hpp></boost/function.hpp></boost/shared_ptr.hpp></boost/thread.hpp>

汎用的な Balking コンテナ

を作ってみた。 #ifndef ANMELT_THREAD_BALKING_CONTAINER_H_INCLUDED #define ANMELT_THREAD_BALKING_CONTAINER_H_INCLUDED // Boost #include <boost/thread.hpp> namespace anmelt{ namespace thread { template<class Container, class Adapter> class balking_container { private: Container container_; </class></boost/thread.hpp>…

汎用的な Blocking コンテナ

を作ってみた。 #ifndef ANMELT_THREAD_BLOCKING_CONTAINER_H_INCLUDED #define ANMELT_THREAD_BLOCKING_CONTAINER_H_INCLUDED // Boost #include <boost/thread.hpp> namespace anmelt{ namespace thread { template<class Container, class Adapter> class blocking_container { private: Container container</class></boost/thread.hpp>…

多重ラムダ

using namespace boost::lambda; template<class F, class T> void apply(F f, T v) { f(v); } void func(std::vector<int>& v) { std::for_each(v.begin(), v.end(), _1 *= 2); } void main() { std::vector<int> v; apply(func, boost::ref(v)); } これを、func 関数を作らずにやるとど</int></int></class>…

間違ったコード

C++

class Item { private: int value_; public: Item(int v) : value_(v) { } void Initialize() { ... } }; class Hoge { private: std::vector<Item*> vec_; public: ~Hoge() { BOOST_FOREACH (Item* p, vec_) delete p; } void add(int n) { std::auto_ptr<Item> item(new</item></item*>…

既存のオブジェクトをスレッドセーフにする

こんなの作ってみました。 #ifndef ANMELT_THREAD_MUTEXED_H_INCLUDED #define ANMELT_THREAD_MUTEXED_H_INCLUDED #include <boost/thread.hpp> #include <boost/utility/enable_if.hpp> #include <boost/utility/result_of.hpp> #include <boost/type_traits/is_void.hpp> namespace anmelt{ namespace thread { template</boost/type_traits/is_void.hpp></boost/utility/result_of.hpp></boost/utility/enable_if.hpp></boost/thread.hpp>

Registrar Script の BNF が腐っている件

Boost.Spirit で何か試しに解析してみようと思って、ちょうどパース ツリーについて (ATL)辺りに BNF で書かれた文法があったので、これを使ってみることにしてみた。 <root key>{<registry expression>}+ <root key> ::= HKEY_CLASSES_ROOT | HKEY_CURRENT_USER | HKEY_LOCAL_MACHINE | HKEY_USERS | </root></registry></root>…

Boost.Spirit を扱う上で絶対に読むべき情報

Debugging この辺のマクロを定義しておかないと、意図しない解析をした場合にエラーの原因を突き止めるのがものすごく困難になる。 実際に困難を極めた人がここにいるので間違いない。

Boost.Spirit に手を出してみた

まずは情報を調べるところから、と思ったらまとめていらっしゃる方がいるようで。http://www5d.biglobe.ne.jp/~y0ka/2006-05-14-1.html で、いろいろ調べた感じ、LL(k) 文法なのでバックトラックが起こったときのセマンティックアクションがなかなか手強いっ…

namespace of melt's library

namespace anmelt { namespace horizontal { } }