[英]trouble compiling std::tuple with clang
I have trouble compiling templates with clang.. Any help appreciated. 我在用clang编译模板时遇到了麻烦。任何帮助。
Although the author of the library claims he compiled below code with gcc on linux, when I try to compile using clang, it complains about compiling templates below: 尽管该库的作者声称他在Linux上使用gcc在下面的代码下进行了编译,但是当我尝试使用clang进行编译时,它却抱怨编译以下模板:
// this gives the error of "expected expression" //这会产生“预期表达式”错误
template<class T1, class T2, class T3> static ostream& operator << (
ostream& out, const std::tuple<T1, T2, T3>& t) {
out << t.get<0>() << " " << t.get<1>() << " " << t.get<2>();
return out;
}
this gives the error: 这给出了错误:
no member named 'get' in 'std::__1::tuple<std::__1::basic_string<char>, std::__1::basic_string<char>, int, int>'
Code: 码:
void save_by_conns(vector<real_t> &container, const string &nam)
{
LOOP(const WC_CONN_PAIR &p, connections)
{
VDI begin = container.begin() + p.second.get<2>();
VDI end = container.begin() + p.second.get<3>();
if (begin != end)
{
save_range(make_pair(begin, end), p.second.get<1>() + "_" + nam);
}
}
}
为了检索tuple
元素,应使用非成员std::get
函数:
out << ::std::get<0>(t) << " " << ::std::get<1>(t) << " " << ::std::get<2>(t);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.