[llvm-bugs] [Bug 46371] New: operator>> function name lookup fails in fold expression std::cin >> ... >> args;
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jun 17 18:18:38 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=46371
Bug ID: 46371
Summary: operator>> function name lookup fails in fold
expression std::cin >> ... >> args;
Product: clang
Version: 10.0
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: C++17
Assignee: unassignedclangbugs at nondot.org
Reporter: zjsdut at 163.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
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 https://godbolt.org/z/wTMzhU
However, the same code compiles and runs correctly with gcc 9.3. Is this code
ill-formed?
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200618/2d0c5d49/attachment.html>
More information about the llvm-bugs
mailing list