summaryrefslogtreecommitdiffstats
path: root/contrib/libc++/include/iterator
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2015-01-15 21:17:36 +0000
committerdim <dim@FreeBSD.org>2015-01-15 21:17:36 +0000
commit80c1930a959a4c0b7f5897afc73176ffcadc4887 (patch)
treec7ef11e9501df78a928c64bb92aa05baf56f5808 /contrib/libc++/include/iterator
parent6449dfa4f9e574a7e65a543b10119ab730a8404d (diff)
parent083c980732b44eb899ce399cf182dec9b90b9a1d (diff)
downloadFreeBSD-src-80c1930a959a4c0b7f5897afc73176ffcadc4887.zip
FreeBSD-src-80c1930a959a4c0b7f5897afc73176ffcadc4887.tar.gz
Import libc++ trunk r224926. This fixes a number of bugs, completes
C++14 support[1], adds more C++1z features[2], and fixes the following LWG issues[3]: 1450: Contradiction in regex_constants 2003: String exception inconsistency in erase. 2075: Progress guarantees, lock-free property, and scheduling assumptions 2104: unique_lock move-assignment should not be noexcept 2112: User-defined classes that cannot be derived from 2132: std::function ambiguity 2135: Unclear requirement for exceptions thrown in condition_variable::wait() 2142: packaged_task::operator() synchronization too broad? 2182: Container::[const_]reference types are misleadingly specified 2186: Incomplete action on async/launch::deferred 2188: Reverse iterator does not fully support targets that overload operator& 2193: Default constructors for standard library containers are explicit 2205: Problematic postconditions of regex_match and regex_search 2213: Return value of std::regex_replace 2240: Probable misuse of term "function scope" in [thread.condition] 2252: Strong guarantee on vector::push_back() still broken with C++11? 2257: Simplify container requirements with the new algorithms 2258: a.erase(q1, q2) unable to directly return q2 2263: Comparing iterators and allocator pointers with different const-character 2268: Setting a default argument in the declaration of a member function assign of std::basic_string 2271: regex_traits::lookup_classname specification unclear 2272: quoted should use char_traits::eq for character comparison 2278: User-defined literals for Standard Library types 2280: begin / end for arrays should be constexpr and noexcept 2285: make_reverse_iterator 2288: Inconsistent requirements for shared mutexes 2291: std::hash is vulnerable to collision DoS attack 2293: Wrong facet used by num_put::do_put 2299: Effects of inaccessible key_compare::is_transparent type are not clear 2301: Why is std::tie not constexpr? 2304: Complexity of count in unordered associative containers 2306: match_results::reference should be value_type&, not const value_type& 2308: Clarify container destructor requirements w.r.t. std::array 2313: tuple_size should always derive from integral_constant<size_t, N> 2314: apply() should return decltype(auto) and use decay_t before tuple_size 2315: weak_ptr should be movable 2316: weak_ptr::lock() should be atomic 2317: The type property queries should be UnaryTypeTraits returning size_t 2320: select_on_container_copy_construction() takes allocators, not containers 2322: Associative(initializer_list, stuff) constructors are underspecified 2323: vector::resize(n, t)'s specification should be simplified 2324: Insert iterator constructors should use addressof() 2329: regex_match()/regex_search() with match_results should forbid temporary strings 2330: regex("meow", regex::icase) is technically forbidden but should be permitted 2332: regex_iterator/regex_token_iterator should forbid temporary regexes 2339: Wording issue in nth_element 2341: Inconsistency between basic_ostream::seekp(pos) and basic_ostream::seekp(off, dir) 2344: quoted()'s interaction with padding is unclear 2346: integral_constant's member functions should be marked noexcept 2350: min, max, and minmax should be constexpr 2356: Stability of erasure in unordered associative containers 2357: Remaining "Assignable" requirement 2359: How does regex_constants::nosubs affect basic_regex::mark_count()? 2360: reverse_iterator::operator*() is unimplementable [1] http://libcxx.llvm.org/cxx1y_status.html [2] http://libcxx.llvm.org/cxx1z_status.html [3] http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html Exp-run: antoine MFC after: 1 month
Diffstat (limited to 'contrib/libc++/include/iterator')
-rw-r--r--contrib/libc++/include/iterator89
1 files changed, 69 insertions, 20 deletions
diff --git a/contrib/libc++/include/iterator b/contrib/libc++/include/iterator
index 70a664d..bcf142a 100644
--- a/contrib/libc++/include/iterator
+++ b/contrib/libc++/include/iterator
@@ -138,6 +138,8 @@ template <class Iterator>
reverse_iterator<Iterator>
operator+(typename reverse_iterator<Iterator>::difference_type n, const reverse_iterator<Iterator>& x);
+template <class Iterator> reverse_iterator<Iterator> make_reverse_iterator(Iterator i); // C++14
+
template <class Container>
class back_insert_iterator
{
@@ -322,11 +324,23 @@ template <class T, size_t N> reverse_iterator<T*> rend(T (&array)[N]); //
template <class C> auto crbegin(const C& c) -> decltype(std::rbegin(c)); // C++14
template <class C> auto crend(const C& c) -> decltype(std::rend(c)); // C++14
+// 24.8, container access:
+template <class C> constexpr auto size(const C& c) -> decltype(c.size()); // C++17
+template <class T, size_t N> constexpr size_t size(const T (&array)[N]) noexcept; // C++17
+template <class C> constexpr auto empty(const C& c) -> decltype(c.empty()); // C++17
+template <class T, size_t N> constexpr bool empty(const T (&array)[N]) noexcept; // C++17
+template <class E> constexpr bool empty(initializer_list<E> il) noexcept; // C++17
+template <class C> constexpr auto data(C& c) -> decltype(c.data()); // C++17
+template <class C> constexpr auto data(const C& c) -> decltype(c.data()); // C++17
+template <class T, size_t N> constexpr T* data(T (&array)[N]) noexcept; // C++17
+template <class E> constexpr const E* data(initializer_list<E> il) noexcept; // C++17
+
} // std
*/
#include <__config>
+#include <__functional_base>
#include <type_traits>
#include <cstddef>
#include <iosfwd>
@@ -335,11 +349,7 @@ template <class C> auto crend(const C& c) -> decltype(std::rend(c)); //
#include <Availability.h>
#endif
-#ifdef _LIBCPP_DEBUG
-# include <__debug>
-#else
-# define _LIBCPP_ASSERT(x, m) ((void)0)
-#endif
+#include <__debug>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -364,10 +374,10 @@ public:
static const bool value = sizeof(__test<_Tp>(0)) == 1;
};
-template <class _Iter, bool> struct ____iterator_traits {};
+template <class _Iter, bool> struct __iterator_traits_impl {};
template <class _Iter>
-struct ____iterator_traits<_Iter, true>
+struct __iterator_traits_impl<_Iter, true>
{
typedef typename _Iter::difference_type difference_type;
typedef typename _Iter::value_type value_type;
@@ -380,7 +390,7 @@ template <class _Iter, bool> struct __iterator_traits {};
template <class _Iter>
struct __iterator_traits<_Iter, true>
- : ____iterator_traits
+ : __iterator_traits_impl
<
_Iter,
is_convertible<typename _Iter::iterator_category, input_iterator_tag>::value ||
@@ -534,7 +544,7 @@ class _LIBCPP_TYPE_VIS_ONLY reverse_iterator
typename iterator_traits<_Iter>::reference>
{
private:
- mutable _Iter __t;
+ mutable _Iter __t; // no longer used as of LWG #2360, not removed due to ABI break
protected:
_Iter current;
public:
@@ -548,8 +558,8 @@ public:
template <class _Up> _LIBCPP_INLINE_VISIBILITY reverse_iterator(const reverse_iterator<_Up>& __u)
: __t(__u.base()), current(__u.base()) {}
_LIBCPP_INLINE_VISIBILITY _Iter base() const {return current;}
- _LIBCPP_INLINE_VISIBILITY reference operator*() const {__t = current; return *--__t;}
- _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return &(operator*());}
+ _LIBCPP_INLINE_VISIBILITY reference operator*() const {_Iter __tmp = current; return *--__tmp;}
+ _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return _VSTD::addressof(operator*());}
_LIBCPP_INLINE_VISIBILITY reverse_iterator& operator++() {--current; return *this;}
_LIBCPP_INLINE_VISIBILITY reverse_iterator operator++(int)
{reverse_iterator __tmp(*this); --current; return __tmp;}
@@ -632,6 +642,15 @@ operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_i
return reverse_iterator<_Iter>(__x.base() - __n);
}
+#if _LIBCPP_STD_VER > 11
+template <class _Iter>
+inline _LIBCPP_INLINE_VISIBILITY
+reverse_iterator<_Iter> make_reverse_iterator(_Iter __i)
+{
+ return reverse_iterator<_Iter>(__i);
+}
+#endif
+
template <class _Container>
class _LIBCPP_TYPE_VIS_ONLY back_insert_iterator
: public iterator<output_iterator_tag,
@@ -645,7 +664,7 @@ protected:
public:
typedef _Container container_type;
- _LIBCPP_INLINE_VISIBILITY explicit back_insert_iterator(_Container& __x) : container(&__x) {}
+ _LIBCPP_INLINE_VISIBILITY explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
_LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(const typename _Container::value_type& __value_)
{container->push_back(__value_); return *this;}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -678,7 +697,7 @@ protected:
public:
typedef _Container container_type;
- _LIBCPP_INLINE_VISIBILITY explicit front_insert_iterator(_Container& __x) : container(&__x) {}
+ _LIBCPP_INLINE_VISIBILITY explicit front_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
_LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(const typename _Container::value_type& __value_)
{container->push_front(__value_); return *this;}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -713,7 +732,7 @@ public:
typedef _Container container_type;
_LIBCPP_INLINE_VISIBILITY insert_iterator(_Container& __x, typename _Container::iterator __i)
- : container(&__x), iter(__i) {}
+ : container(_VSTD::addressof(__x)), iter(__i) {}
_LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(const typename _Container::value_type& __value_)
{iter = container->insert(iter, __value_); ++iter; return *this;}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -1386,7 +1405,7 @@ operator+(typename __wrap_iter<_Iter>::difference_type __n,
}
template <class _Tp, size_t _Np>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp*
begin(_Tp (&__array)[_Np])
{
@@ -1394,7 +1413,7 @@ begin(_Tp (&__array)[_Np])
}
template <class _Tp, size_t _Np>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp*
end(_Tp (&__array)[_Np])
{
@@ -1466,17 +1485,17 @@ reverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il)
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
auto cbegin(const _Cp& __c) -> decltype(begin(__c))
{
- return _VSTD::begin(__c);
+ return begin(__c);
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
auto cend(const _Cp& __c) -> decltype(end(__c))
{
- return _VSTD::end(__c);
+ return end(__c);
}
template <class _Cp>
@@ -1560,6 +1579,36 @@ end(const _Cp& __c)
#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN)
+#if _LIBCPP_STD_VER > 14
+template <class _C>
+constexpr auto size(const _C& __c) -> decltype(__c.size()) { return __c.size(); }
+
+template <class _Tp, size_t _N>
+constexpr size_t size(const _Tp (&__array)[_N]) noexcept { return _N; }
+
+template <class _C>
+constexpr auto empty(const _C& __c) -> decltype(__c.empty()) { return __c.empty(); }
+
+template <class _Tp, size_t _N>
+constexpr bool empty(const _Tp (&__array)[_N]) noexcept { return false; }
+
+template <class _Ep>
+constexpr bool empty(initializer_list<_Ep> __il) noexcept { return __il.size() == 0; }
+
+template <class _C> constexpr
+auto data(_C& __c) -> decltype(__c.data()) { return __c.data(); }
+
+template <class _C> constexpr
+auto data(const _C& __c) -> decltype(__c.data()) { return __c.data(); }
+
+template <class _Tp, size_t _N>
+constexpr _Tp* data(_Tp (&__array)[_N]) noexcept { return __array; }
+
+template <class _Ep>
+constexpr const _Ep* data(initializer_list<_Ep> __il) noexcept { return __il.begin(); }
+#endif
+
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_ITERATOR
OpenPOWER on IntegriCloud