あめだまふぁくとりー

Boost.Graphとかできますん

2012年は本気を出すといったな.あれは嘘だ.

資格のための勉強っていまいちやる気がでないのよね.TOEICとかも同じ.でもこつこつやらんといかんのよね.

昨日のやつ

d:id:amedama41:20120104でproperty_map_functionのサンプルコード書いたけどあれよく考えたら別にmake_property_map_functionいらないじゃん.普通にこれ↓でいける.

std::transform(edges(g).first, edges(g).second,
        std::ostream_iterator<int>(std::cout, " "),
        get(edge_weight, g));

get(edge_weight, g)でプロパティマップが戻ってくるんだけど,BGL内で定義されているプロパティマップは全部(adjacency_listだけかも)operator()をオーバロードしているから関数オブジェクトとして使うことができる.実装に依存している気もしないが,プロパティマップはoperator[]でなくoperator()を使うべきだみたいな意見があったはずだからいつかスタンダードになるかもね.ちなみにこれ↓は無理.

std::copy(make_transform_iterator(edges(g).first,  get(edge_weight, g)),
          make_transform_iterator(edges(g).second, get(edge_weight, g)),
          std::ostream_iterator<int>(std::cout, " "));

プロパティマップは結果の型をresult_typeでなく,value_typeでtypedefしているのでresult_typeを必要とするときはproperty_map_functionを使うことになる.