<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - operator>> function name lookup fails in fold expression std::cin >> ... >> args;"
href="https://bugs.llvm.org/show_bug.cgi?id=46371">46371</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>operator>> function name lookup fails in fold expression std::cin >> ... >> args;
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>10.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++17
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>zjsdut@163.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>The following code
#include <iostream>
#include <vector>
namespace io {
template<typename T>
std::istream &operator>>(std::istream &in, std::vector<T> &vec) {
for (auto &x : vec)
in >> x;
return in;
}
template<class... Args> void scan(Args &... args) {
(std::cin >> ... >> args);
}
}// namespace io
int main() {
std::vector<int> s(1), t(1);
io::scan(s, t);
std::cout << s[0] << ' ' << t[0] << '\n';
}
does not compile with clang 10.0.0:
<source>:13:16: error: call to function 'operator>>' that is neither visible in
the template definition nor found by argument-dependent lookup
(std::cin >> ... >> args);
^
<source>:19:9: note: in instantiation of function template specialization
'io::scan<std::vector<int, std::allocator<int> >, std::vector<int,
std::allocator<int> > >' requested here
io::scan(s, t);
^
<source>:6:15: note: 'operator>>' should be declared prior to the call site
std::istream &operator>>(std::istream &in, std::vector<T> &vec) {
^
1 error generated.
See <a href="https://godbolt.org/z/wTMzhU">https://godbolt.org/z/wTMzhU</a>
However, the same code compiles and runs correctly with gcc 9.3. Is this code
ill-formed?</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>