https://bugs.llvm.org/show_bug.cgi?id=32006
Bug ID: 32006
Summary: pointer_traits for __wrap_iter types sometimes
produces nonsense
Product: libc++
Version: 4.0
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: All Bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
This is more of an enhancement request than a bug, I think, because I don't see
anywhere that the Standard actually specifies what counts as a "pointer-like
type". However, here's the problem:
In general, it is true (by accident, not by specification) that
pointer_traits<T>::element_type ==
remove_reference_t<decltype(*declval<T>())>
But when you set T == std::vector<int>::iterator, you find that
pointer_traits<T>::element_type == T::pointer_type
instead.
http://melpon.org/wandbox/permlink/pscCG6PVumWexxeN
This is because for any type of the form X<Y>, the standard mandates that
pointer_traits<X<Y>>::element_type == Y. So when you feed in
std::vector<int>::iterator a.k.a. __wrap_iter<int*>, element_type comes out as
(int*).
Additionally, this nerfs the libc++ extension function "__to_raw_pointer" for
contiguous iterators.
int *p = std::__to_raw_pointer(myvector.end());
does not compile.
http://melpon.org/wandbox/permlink/LL61wlsNYdEtQX1X
This could be resolved by
- closing as NOTABUG since iterator types are not "pointer-like"; or
- adding an element_type typedef to libc++'s __wrap_iter; or
- adding a partial specialization for pointer_traits<__wrap_iter<Y>>.
The discussion that led to this "discovery" was
https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/PBETQcQHB-0
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs