habara-k / ICPCLibrary

https://habara-k.github.io/ICPCLibrary/
3 stars 0 forks source link

Add edge constructo in graph/template.cpp #3

Closed kanra824 closed 4 years ago

kanra824 commented 4 years ago

graphテンプレート中にedgeのコンストラクタがなかったので追加した

habara-k commented 4 years ago
vector<vector<edge>> G(n);
G[i].push_back({src, to, cost})

でコンストラクタなしで動くので、テンプレートを書く手間と天秤だな〜と思ってました。 https://github.com/habara-k/ICPCLibrary/blob/master/test/graph/dijkstra.cpp#L12

ライブラリには書いておいて、当日は書かなくても良いとわかるようにしておくのがいいかな...

habara-k commented 4 years ago
struct edge {
    int src, to;
    T cost;
    // edge(int src, int to, T cost): src(src), to(to), cost(cost) {}
    // // G[i].push_back({src, to, cost}) requires no constructor
};
kanra824 commented 4 years ago

あー初期化子そういう場合にも使えるのか(普段そういう使い方しないから絶対{}忘れそう)

habara-k commented 4 years ago

マージしちゃいます