0
我觉得这个问题很愚蠢,但我真的很想知道在我未来的代码中严重“键入两次”之前的原因。C++ 11为什么需要为priority_queue构造比较两次信息
例如,我从myVector(代码之前所定义的向量)构建绝对最大priority_queue:
auto comp = [](int a, int b) { return abs(a) < abs(b); };
priority_queue<int, vector<int>, decltype(comp)> pq(comp, myVector);
的排版拉姆达需要填写模板(我同意,因为这个priority_queue实例将在其生命中具有该订单属性),并且还需要在构造函数中(这使我感到困惑)。
为什么构造函数不能从模板中的订单信息中推导出订单?
由于lambdas不是默认可构造的。 – 2015-04-02 18:42:12
@ T.C。你能否详细说明你的评论? – 8090PZ 2015-04-02 19:35:29
可能的重复[模板类型演绎在C + +类或功能?](http://stackoverflow.com/questions/1921817/template-type-deduction-in-c-for-class-vs-function) – quamrana 2015-04-02 19:48:39