【发布时间】:2014-09-17 23:09:05
【问题描述】:
根据我之前关于 std::pair 的 question,我认为我可以执行以下操作,但它不会编译。
typedef Point::FT float;
std::vector<std::tuple<Point::FT, int, int> > branch{ (int)(max_leaf_check * mul_factor),
{ std::numeric_limits<Point::FT>::max(), -1 , -1} };
错误:
error: converting to ‘const value_type {aka const std::tuple<float, int, int>}’ from initializer list would use explicit constructor ‘std::tuple< <template-parameter-1-1> >::tuple(_UElements&& ...) [with _UElements = {float, int, int}, <template-parameter-2-2> = void, _Elements = {float, int, int}]’
我该如何解决?如果无法修复,有没有其他方法可以在一行中进行初始化?
作为后续,我什至无法使用 push_back()。
Point::FT new_dist;
size_t other_child_i, tree_i;
branch.push_back({new_dist, other_child_i, tree_i});
类似的错误。
【问题讨论】: