Index: include/__config =================================================================== --- include/__config +++ include/__config @@ -102,6 +102,8 @@ # define _LIBCPP_ABI_OPTIMIZED_FUNCTION // All the regex constants must be distinct and nonzero. # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO +// Fix std::vector::const_reference to actually be a bool. +#define _LIBCPP_ABI_VECTOR_BOOL_CORRECT_CONST_REFERENCE_TYPE #elif _LIBCPP_ABI_VERSION == 1 # if !defined(_LIBCPP_OBJECT_FORMAT_COFF) // Enable compiling copies of now inline methods into the dylib to support Index: include/vector =================================================================== --- include/vector +++ include/vector @@ -2217,8 +2217,13 @@ size_type __size_; __compressed_pair __cap_alloc_; public: - typedef __bit_reference reference; - typedef __bit_const_reference const_reference; + typedef __bit_const_reference __const_ref; + typedef __bit_reference reference; +#ifdef _LIBCPP_ABI_VECTOR_BOOL_CORRECT_CONST_REFERENCE_TYPE + typedef bool const_reference; +#else + typedef __bit_const_reference const_reference; +#endif private: _LIBCPP_INLINE_VISIBILITY size_type& __cap() _NOEXCEPT @@ -2415,7 +2420,7 @@ iterator insert(const_iterator __position, const value_type& __x); iterator insert(const_iterator __position, size_type __n, const value_type& __x); - iterator insert(const_iterator __position, size_type __n, const_reference __x); + template typename enable_if < @@ -2479,8 +2484,10 @@ reference __make_ref(size_type __pos) _NOEXCEPT {return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} _LIBCPP_INLINE_VISIBILITY - const_reference __make_ref(size_type __pos) const _NOEXCEPT - {return const_reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} + __const_ref __make_ref(size_type __pos) const _NOEXCEPT { + return __const_ref(__begin_ + __pos / __bits_per_word, + __storage_type(1) << __pos % __bits_per_word); + } _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_type __pos) _NOEXCEPT {return iterator(__begin_ + __pos / __bits_per_word, static_cast(__pos % __bits_per_word));} Index: test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp =================================================================== --- test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp +++ test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp @@ -63,6 +63,12 @@ for (++j; j < v.size(); ++j) assert(v[j] == 0); } + { + std::vector v(100); + const auto& cv = v; + std::vector v2; + v2.insert(v2.begin(), 3, cv[0]); + } #if TEST_STD_VER >= 11 { std::vector> v(100); Index: test/std/containers/sequences/vector.bool/types.pass.cpp =================================================================== --- test/std/containers/sequences/vector.bool/types.pass.cpp +++ test/std/containers/sequences/vector.bool/types.pass.cpp @@ -30,6 +30,7 @@ #include #include +#include "test_macros.h" #include "test_allocator.h" #include "../../Copyable.h" #include "min_allocator.h" @@ -40,39 +41,46 @@ { typedef std::vector C; - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::size_type>::value), ""); - static_assert((std::is_same::difference_type>::value), ""); + ASSERT_SAME_TYPE(typename C::value_type, bool); + ASSERT_SAME_TYPE(typename C::value_type, typename Allocator::value_type); + ASSERT_SAME_TYPE(typename C::allocator_type, Allocator); + ASSERT_SAME_TYPE(typename C::size_type, + typename std::allocator_traits::size_type); + ASSERT_SAME_TYPE( + typename C::difference_type, + typename std::allocator_traits::difference_type); static_assert((std::is_signed::value), ""); static_assert((std::is_unsigned::value), ""); - static_assert((std::is_same::difference_type>::value), ""); - static_assert((std::is_same::difference_type>::value), ""); + ASSERT_SAME_TYPE( + typename C::difference_type, + typename std::iterator_traits::difference_type); + ASSERT_SAME_TYPE(typename C::difference_type, + typename std::iterator_traits< + typename C::const_iterator>::difference_type); - static_assert((std::is_same< + ASSERT_SAME_TYPE( typename std::iterator_traits::iterator_category, - std::random_access_iterator_tag>::value), ""); - static_assert((std::is_same< - typename std::iterator_traits::iterator_category, - std::random_access_iterator_tag>::value), ""); - static_assert((std::is_same< - typename C::reverse_iterator, - std::reverse_iterator >::value), ""); - static_assert((std::is_same< - typename C::const_reverse_iterator, - std::reverse_iterator >::value), ""); + std::random_access_iterator_tag); + ASSERT_SAME_TYPE(typename std::iterator_traits< + typename C::const_iterator>::iterator_category, + std::random_access_iterator_tag); + ASSERT_SAME_TYPE(typename C::reverse_iterator, + std::reverse_iterator); + ASSERT_SAME_TYPE(typename C::const_reverse_iterator, + std::reverse_iterator); + +#if !defined(_LIBCPP_VERSION) || \ + defined(_LIBCPP_ABI_VECTOR_BOOL_CORRECT_CONST_REFERENCE_TYPE) + ASSERT_SAME_TYPE(typename C::const_reference, bool); +#endif } int main(int, char**) { test >(); test >(); - static_assert((std::is_same::allocator_type, - std::allocator >::value), ""); + ASSERT_SAME_TYPE(std::vector::allocator_type, std::allocator); #if TEST_STD_VER >= 11 test >(); #endif