Michael van der Westhuizen: The attached patch add support for building against libc++abi and libcxxrt to CMake builds of libc++.
Usage (with the appropriate CC and CXX environment variables) is:
$ cmake -DLIBCXX_CXX_ABI=libcxxabi '-DLIBCXX_LIBCXXABI_INCLUDE_PATHS=/home/michael/libcxxabi/include' ../libcxx
and:
$ cmake -DLIBCXX_CXX_ABI=libcxxrt '-DLIBCXX_LIBCXXRT_INCLUDE_PATHS=/home/michael/libcxxrt/src' ../libcxx
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@174623 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/vector b/include/vector
index 876b7e5..f4a41d6 100644
--- a/include/vector
+++ b/include/vector
@@ -440,7 +440,7 @@
__vector_base<_Tp, _Allocator>::__destruct_at_end(const_pointer __new_last, false_type) _NOEXCEPT
{
while (__new_last != __end_)
- __alloc_traits::destroy(__alloc(), const_cast<pointer>(--__end_));
+ __alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__end_));
}
template <class _Tp, class _Allocator>
@@ -448,7 +448,7 @@
void
__vector_base<_Tp, _Allocator>::__destruct_at_end(const_pointer __new_last, true_type) _NOEXCEPT
{
- __end_ = const_cast<pointer>(__new_last);
+ __end_ = static_cast<pointer>(__new_last);
}
template <class _Tp, class _Allocator>
@@ -1550,7 +1550,7 @@
"vector::erase(iterator) called with an iterator not"
" referring to this vector");
#endif
- pointer __p = const_cast<pointer>(&*__position);
+ pointer __p = this->__begin_ + (__position - cbegin());
iterator __r = __make_iter(__p);
this->__destruct_at_end(_VSTD::move(__p + 1, this->__end_, __p));
return __r;