https://bugs.llvm.org/show_bug.cgi?id=47497
Bug ID: 47497
Summary: vector (iterator,iterator) constructor doesn't deduce
second arg
Product: libc++
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: All Bugs
Assignee: unassignedclangb...@nondot.org
Reporter: logan.r.smi...@gmail.com
CC: llvm-bugs@lists.llvm.org, mclow.li...@gmail.com
The following code is rejected by libc++ because the second iterator argument
to vector(iterator, iterator) is not deduced (https://godbolt.org/z/q8f9Y7):
#include <iterator>
#include <iostream>
#include <vector>
int main() {
std::vector<int> v({}, std::istream_iterator<int>{});
}
The the following code, however, is accepted (https://godbolt.org/z/nM4Yh4):
#include <iterator>
#include <iostream>
#include <vector>
int main() {
std::vector<int> v;
v.assign({}, std::istream_iterator<int>{});
}
I believe this to be a conformance bug.
I stumbled on this in my own code when I noticed that a typo in the following
code was being accepted:
std::vector<int> v(other.cbegin(), other.end()); // note .end(), not .cend()
Since the second argument is not deduced, and the first argument is a const
iterator, the second argument is implicitly converted to a const iterator. This
is a symptom of the same issue, though I think this particular case could
arguably be considered a conforming extension.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs