visibility-decoration.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@114470 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant 2010-09-21 20:16:37 +00:00
parent b0be42b2ce
commit 333f50d30c
7 changed files with 149 additions and 65 deletions

View File

@ -20,11 +20,12 @@
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
class mutex class _LIBCPP_VISIBLE mutex
{ {
pthread_mutex_t __m_; pthread_mutex_t __m_;
public: public:
_LIBCPP_INLINE_VISIBILITY
mutex() {__m_ = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;} mutex() {__m_ = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;}
~mutex(); ~mutex();
@ -38,12 +39,12 @@ public:
void unlock(); void unlock();
typedef pthread_mutex_t* native_handle_type; typedef pthread_mutex_t* native_handle_type;
native_handle_type native_handle() {return &__m_;} _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__m_;}
}; };
struct defer_lock_t {}; struct _LIBCPP_VISIBLE defer_lock_t {};
struct try_to_lock_t {}; struct _LIBCPP_VISIBLE try_to_lock_t {};
struct adopt_lock_t {}; struct _LIBCPP_VISIBLE adopt_lock_t {};
//constexpr //constexpr
extern const extern const
@ -58,7 +59,7 @@ extern const
adopt_lock_t adopt_lock; adopt_lock_t adopt_lock;
template <class _Mutex> template <class _Mutex>
class lock_guard class _LIBCPP_VISIBLE lock_guard
{ {
public: public:
typedef _Mutex mutex_type; typedef _Mutex mutex_type;
@ -67,10 +68,13 @@ private:
mutex_type& __m_; mutex_type& __m_;
public: public:
_LIBCPP_INLINE_VISIBILITY
explicit lock_guard(mutex_type& __m) explicit lock_guard(mutex_type& __m)
: __m_(__m) {__m_.lock();} : __m_(__m) {__m_.lock();}
_LIBCPP_INLINE_VISIBILITY
lock_guard(mutex_type& __m, adopt_lock_t) lock_guard(mutex_type& __m, adopt_lock_t)
: __m_(__m) {} : __m_(__m) {}
_LIBCPP_INLINE_VISIBILITY
~lock_guard() {__m_.unlock();} ~lock_guard() {__m_.unlock();}
private: private:
@ -79,7 +83,7 @@ private:
}; };
template <class _Mutex> template <class _Mutex>
class unique_lock class _LIBCPP_VISIBLE unique_lock
{ {
public: public:
typedef _Mutex mutex_type; typedef _Mutex mutex_type;
@ -89,21 +93,29 @@ private:
bool __owns_; bool __owns_;
public: public:
_LIBCPP_INLINE_VISIBILITY
unique_lock() : __m_(nullptr), __owns_(false) {} unique_lock() : __m_(nullptr), __owns_(false) {}
_LIBCPP_INLINE_VISIBILITY
explicit unique_lock(mutex_type& __m) explicit unique_lock(mutex_type& __m)
: __m_(&__m), __owns_(true) {__m_->lock();} : __m_(&__m), __owns_(true) {__m_->lock();}
_LIBCPP_INLINE_VISIBILITY
unique_lock(mutex_type& __m, defer_lock_t) unique_lock(mutex_type& __m, defer_lock_t)
: __m_(&__m), __owns_(false) {} : __m_(&__m), __owns_(false) {}
_LIBCPP_INLINE_VISIBILITY
unique_lock(mutex_type& __m, try_to_lock_t) unique_lock(mutex_type& __m, try_to_lock_t)
: __m_(&__m), __owns_(__m.try_lock()) {} : __m_(&__m), __owns_(__m.try_lock()) {}
_LIBCPP_INLINE_VISIBILITY
unique_lock(mutex_type& __m, adopt_lock_t) unique_lock(mutex_type& __m, adopt_lock_t)
: __m_(&__m), __owns_(true) {} : __m_(&__m), __owns_(true) {}
template <class _Clock, class _Duration> template <class _Clock, class _Duration>
_LIBCPP_INLINE_VISIBILITY
unique_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __t) unique_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __t)
: __m_(&__m), __owns_(__m.try_lock_until(__t)) {} : __m_(&__m), __owns_(__m.try_lock_until(__t)) {}
template <class _Rep, class _Period> template <class _Rep, class _Period>
_LIBCPP_INLINE_VISIBILITY
unique_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __d) unique_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __d)
: __m_(&__m), __owns_(__m.try_lock_for(__d)) {} : __m_(&__m), __owns_(__m.try_lock_for(__d)) {}
_LIBCPP_INLINE_VISIBILITY
~unique_lock() ~unique_lock()
{ {
if (__owns_) if (__owns_)
@ -116,9 +128,11 @@ private:
public: public:
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
unique_lock(unique_lock&& __u) unique_lock(unique_lock&& __u)
: __m_(__u.__m_), __owns_(__u.__owns_) : __m_(__u.__m_), __owns_(__u.__owns_)
{__u.__m_ = nullptr; __u.__owns_ = false;} {__u.__m_ = nullptr; __u.__owns_ = false;}
_LIBCPP_INLINE_VISIBILITY
unique_lock& operator=(unique_lock&& __u) unique_lock& operator=(unique_lock&& __u)
{ {
if (__owns_) if (__owns_)
@ -141,11 +155,13 @@ public:
void unlock(); void unlock();
_LIBCPP_INLINE_VISIBILITY
void swap(unique_lock& __u) void swap(unique_lock& __u)
{ {
_STD::swap(__m_, __u.__m_); _STD::swap(__m_, __u.__m_);
_STD::swap(__owns_, __u.__owns_); _STD::swap(__owns_, __u.__owns_);
} }
_LIBCPP_INLINE_VISIBILITY
mutex_type* release() mutex_type* release()
{ {
mutex_type* __m = __m_; mutex_type* __m = __m_;
@ -154,9 +170,12 @@ public:
return __m; return __m;
} }
_LIBCPP_INLINE_VISIBILITY
bool owns_lock() const {return __owns_;} bool owns_lock() const {return __owns_;}
_LIBCPP_INLINE_VISIBILITY
// explicit // explicit
operator bool () const {return __owns_;} operator bool () const {return __owns_;}
_LIBCPP_INLINE_VISIBILITY
mutex_type* mutex() const {return __m_;} mutex_type* mutex() const {return __m_;}
}; };
@ -221,11 +240,11 @@ unique_lock<_Mutex>::unlock()
} }
template <class _Mutex> template <class _Mutex>
inline inline _LIBCPP_INLINE_VISIBILITY
void void
swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y) {__x.swap(__y);} swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y) {__x.swap(__y);}
struct cv_status struct _LIBCPP_VISIBLE cv_status
{ {
enum _ { enum _ {
no_timeout, no_timeout,
@ -234,15 +253,16 @@ struct cv_status
_ __v_; _ __v_;
cv_status(_ __v) : __v_(__v) {} _LIBCPP_INLINE_VISIBILITY cv_status(_ __v) : __v_(__v) {}
operator int() const {return __v_;} _LIBCPP_INLINE_VISIBILITY operator int() const {return __v_;}
}; };
class condition_variable class _LIBCPP_VISIBLE condition_variable
{ {
pthread_cond_t __cv_; pthread_cond_t __cv_;
public: public:
_LIBCPP_INLINE_VISIBILITY
condition_variable() {__cv_ = (pthread_cond_t)PTHREAD_COND_INITIALIZER;} condition_variable() {__cv_ = (pthread_cond_t)PTHREAD_COND_INITIALIZER;}
~condition_variable(); ~condition_variable();
@ -286,7 +306,7 @@ public:
_Predicate __pred); _Predicate __pred);
typedef pthread_cond_t* native_handle_type; typedef pthread_cond_t* native_handle_type;
native_handle_type native_handle() {return &__cv_;} _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__cv_;}
private: private:
void __do_timed_wait(unique_lock<mutex>& __lk, void __do_timed_wait(unique_lock<mutex>& __lk,
@ -294,7 +314,7 @@ private:
}; };
template <class _To, class _Rep, class _Period> template <class _To, class _Rep, class _Period>
inline inline _LIBCPP_INLINE_VISIBILITY
typename enable_if typename enable_if
< <
chrono::__is_duration<_To>::value, chrono::__is_duration<_To>::value,
@ -370,7 +390,7 @@ condition_variable::wait_for(unique_lock<mutex>& __lk,
} }
template <class _Rep, class _Period, class _Predicate> template <class _Rep, class _Period, class _Predicate>
inline inline _LIBCPP_INLINE_VISIBILITY
bool bool
condition_variable::wait_for(unique_lock<mutex>& __lk, condition_variable::wait_for(unique_lock<mutex>& __lk,
const chrono::duration<_Rep, _Period>& __d, const chrono::duration<_Rep, _Period>& __d,

View File

@ -132,23 +132,29 @@ public:
bool __invariants() const; bool __invariants() const;
private: private:
_LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(const __split_buffer& __c, true_type) void __move_assign_alloc(const __split_buffer& __c, true_type)
{ {
__alloc() = _STD::move(__c.__alloc()); __alloc() = _STD::move(__c.__alloc());
} }
_LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(const __split_buffer& __c, false_type) void __move_assign_alloc(const __split_buffer& __c, false_type)
{} {}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(__alloc_rr& __x, __alloc_rr& __y) static void __swap_alloc(__alloc_rr& __x, __alloc_rr& __y)
{__swap_alloc(__x, __y, integral_constant<bool, {__swap_alloc(__x, __y, integral_constant<bool,
__alloc_traits::propagate_on_container_swap::value>());} __alloc_traits::propagate_on_container_swap::value>());}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(__alloc_rr& __x, __alloc_rr& __y, true_type) static void __swap_alloc(__alloc_rr& __x, __alloc_rr& __y, true_type)
{ {
using _STD::swap; using _STD::swap;
swap(__x, __y); swap(__x, __y);
} }
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(__alloc_rr& __x, __alloc_rr& __y, false_type) static void __swap_alloc(__alloc_rr& __x, __alloc_rr& __y, false_type)
{} {}
}; };

View File

@ -64,7 +64,9 @@ public:
} }
_LIBCPP_INLINE_VISIBILITY size_type max_size() const throw() {return size_type(~0) / sizeof(_Tp);} _LIBCPP_INLINE_VISIBILITY size_type max_size() const throw() {return size_type(~0) / sizeof(_Tp);}
_LIBCPP_INLINE_VISIBILITY
bool operator==(__sso_allocator& __a) const {return &buf_ == &__a.buf_;} bool operator==(__sso_allocator& __a) const {return &buf_ == &__a.buf_;}
_LIBCPP_INLINE_VISIBILITY
bool operator!=(__sso_allocator& __a) const {return &buf_ != &__a.buf_;} bool operator!=(__sso_allocator& __a) const {return &buf_ != &__a.buf_;}
}; };

View File

@ -22,12 +22,12 @@
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
template <class, class, class> class __tree; template <class, class, class> class __tree;
template <class, class, class> class __tree_iterator; template <class, class, class> class _LIBCPP_VISIBLE __tree_iterator;
template <class, class, class> class __tree_const_iterator; template <class, class, class> class _LIBCPP_VISIBLE __tree_const_iterator;
template <class, class, class, class> class map; template <class, class, class, class> class _LIBCPP_VISIBLE map;
template <class, class, class, class> class multimap; template <class, class, class, class> class _LIBCPP_VISIBLE multimap;
template <class, class, class> class set; template <class, class, class> class _LIBCPP_VISIBLE set;
template <class, class, class> class multiset; template <class, class, class> class _LIBCPP_VISIBLE multiset;
/* /*
@ -53,7 +53,7 @@ __root, have a non-null __parent_ field.
// Returns: true if __x is a left child of its parent, else false // Returns: true if __x is a left child of its parent, else false
// Precondition: __x != nullptr. // Precondition: __x != nullptr.
template <class _NodePtr> template <class _NodePtr>
inline inline _LIBCPP_INLINE_VISIBILITY
bool bool
__tree_is_left_child(_NodePtr __x) __tree_is_left_child(_NodePtr __x)
{ {
@ -119,7 +119,7 @@ __tree_invariant(_NodePtr __root)
// Returns: pointer to the left-most node under __x. // Returns: pointer to the left-most node under __x.
// Precondition: __x != nullptr. // Precondition: __x != nullptr.
template <class _NodePtr> template <class _NodePtr>
inline inline _LIBCPP_INLINE_VISIBILITY
_NodePtr _NodePtr
__tree_min(_NodePtr __x) __tree_min(_NodePtr __x)
{ {
@ -131,7 +131,7 @@ __tree_min(_NodePtr __x)
// Returns: pointer to the right-most node under __x. // Returns: pointer to the right-most node under __x.
// Precondition: __x != nullptr. // Precondition: __x != nullptr.
template <class _NodePtr> template <class _NodePtr>
inline inline _LIBCPP_INLINE_VISIBILITY
_NodePtr _NodePtr
__tree_max(_NodePtr __x) __tree_max(_NodePtr __x)
{ {
@ -513,11 +513,13 @@ private:
public: public:
bool __value_constructed; bool __value_constructed;
_LIBCPP_INLINE_VISIBILITY
explicit __tree_node_destructor(allocator_type& __na) explicit __tree_node_destructor(allocator_type& __na)
: __na_(__na), : __na_(__na),
__value_constructed(false) __value_constructed(false)
{} {}
_LIBCPP_INLINE_VISIBILITY
void operator()(pointer __p) void operator()(pointer __p)
{ {
if (__value_constructed) if (__value_constructed)
@ -538,6 +540,7 @@ public:
typedef _Pointer pointer; typedef _Pointer pointer;
pointer __left_; pointer __left_;
_LIBCPP_INLINE_VISIBILITY
__tree_end_node() : __left_() {} __tree_end_node() : __left_() {}
}; };
@ -576,6 +579,7 @@ public:
pointer __parent_; pointer __parent_;
bool __is_black_; bool __is_black_;
_LIBCPP_INLINE_VISIBILITY
__tree_node_base() : __right_(), __parent_(), __is_black_(false) {} __tree_node_base() : __right_(), __parent_(), __is_black_(false) {}
}; };
@ -591,9 +595,11 @@ public:
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
template <class ..._Args> template <class ..._Args>
_LIBCPP_INLINE_VISIBILITY
explicit __tree_node(_Args&& ...__args) explicit __tree_node(_Args&& ...__args)
: __value_(_STD::forward<_Args>(__args)...) {} : __value_(_STD::forward<_Args>(__args)...) {}
#else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) #else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
_LIBCPP_INLINE_VISIBILITY
explicit __tree_node(const value_type& __v) explicit __tree_node(const value_type& __v)
: __value_(__v) {} : __value_(__v) {}
#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) #endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
@ -603,7 +609,7 @@ template <class> class __map_iterator;
template <class> class __map_const_iterator; template <class> class __map_const_iterator;
template <class _Tp, class _NodePtr, class _DiffType> template <class _Tp, class _NodePtr, class _DiffType>
class __tree_iterator class _LIBCPP_VISIBLE __tree_iterator
{ {
typedef _NodePtr __node_pointer; typedef _NodePtr __node_pointer;
typedef typename pointer_traits<__node_pointer>::element_type __node; typedef typename pointer_traits<__node_pointer>::element_type __node;
@ -626,41 +632,48 @@ public:
#endif #endif
pointer; pointer;
__tree_iterator() {} _LIBCPP_INLINE_VISIBILITY __tree_iterator() {}
reference operator*() const {return __ptr_->__value_;} _LIBCPP_INLINE_VISIBILITY reference operator*() const {return __ptr_->__value_;}
pointer operator->() const {return &__ptr_->__value_;} _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return &__ptr_->__value_;}
_LIBCPP_INLINE_VISIBILITY
__tree_iterator& operator++() __tree_iterator& operator++()
{__ptr_ = static_cast<__node_pointer>(__tree_next(static_cast<__node_base_pointer>(__ptr_))); {__ptr_ = static_cast<__node_pointer>(__tree_next(static_cast<__node_base_pointer>(__ptr_)));
return *this;} return *this;}
_LIBCPP_INLINE_VISIBILITY
__tree_iterator operator++(int) __tree_iterator operator++(int)
{__tree_iterator __t(*this); ++(*this); return __t;} {__tree_iterator __t(*this); ++(*this); return __t;}
_LIBCPP_INLINE_VISIBILITY
__tree_iterator& operator--() __tree_iterator& operator--()
{__ptr_ = static_cast<__node_pointer>(__tree_prev(static_cast<__node_base_pointer>(__ptr_))); {__ptr_ = static_cast<__node_pointer>(__tree_prev(static_cast<__node_base_pointer>(__ptr_)));
return *this;} return *this;}
_LIBCPP_INLINE_VISIBILITY
__tree_iterator operator--(int) __tree_iterator operator--(int)
{__tree_iterator __t(*this); --(*this); return __t;} {__tree_iterator __t(*this); --(*this); return __t;}
friend bool operator==(const __tree_iterator& __x, const __tree_iterator& __y) friend _LIBCPP_INLINE_VISIBILITY
bool operator==(const __tree_iterator& __x, const __tree_iterator& __y)
{return __x.__ptr_ == __y.__ptr_;} {return __x.__ptr_ == __y.__ptr_;}
friend bool operator!=(const __tree_iterator& __x, const __tree_iterator& __y) friend _LIBCPP_INLINE_VISIBILITY
bool operator!=(const __tree_iterator& __x, const __tree_iterator& __y)
{return !(__x == __y);} {return !(__x == __y);}
private: private:
_LIBCPP_INLINE_VISIBILITY
explicit __tree_iterator(__node_pointer __p) : __ptr_(__p) {} explicit __tree_iterator(__node_pointer __p) : __ptr_(__p) {}
template <class, class, class> friend class __tree; template <class, class, class> friend class __tree;
template <class, class, class> friend class __tree_const_iterator; template <class, class, class> friend class _LIBCPP_VISIBLE __tree_const_iterator;
template <class> friend class __map_iterator; template <class> friend class _LIBCPP_VISIBLE __map_iterator;
template <class, class, class, class> friend class map; template <class, class, class, class> friend class _LIBCPP_VISIBLE map;
template <class, class, class, class> friend class multimap; template <class, class, class, class> friend class _LIBCPP_VISIBLE multimap;
template <class, class, class> friend class set; template <class, class, class> friend class _LIBCPP_VISIBLE set;
template <class, class, class> friend class multiset; template <class, class, class> friend class _LIBCPP_VISIBLE multiset;
}; };
template <class _Tp, class _ConstNodePtr, class _DiffType> template <class _Tp, class _ConstNodePtr, class _DiffType>
class __tree_const_iterator class _LIBCPP_VISIBLE __tree_const_iterator
{ {
typedef _ConstNodePtr __node_pointer; typedef _ConstNodePtr __node_pointer;
typedef typename pointer_traits<__node_pointer>::element_type __node; typedef typename pointer_traits<__node_pointer>::element_type __node;
@ -689,7 +702,7 @@ public:
#endif #endif
pointer; pointer;
__tree_const_iterator() {} _LIBCPP_INLINE_VISIBILITY __tree_const_iterator() {}
private: private:
typedef typename remove_const<__node>::type __non_const_node; typedef typename remove_const<__node>::type __non_const_node;
typedef typename pointer_traits<__node_pointer>::template typedef typename pointer_traits<__node_pointer>::template
@ -702,36 +715,44 @@ private:
typedef __tree_iterator<value_type, __non_const_node_pointer, difference_type> typedef __tree_iterator<value_type, __non_const_node_pointer, difference_type>
__non_const_iterator; __non_const_iterator;
public: public:
_LIBCPP_INLINE_VISIBILITY
__tree_const_iterator(__non_const_iterator __p) : __ptr_(__p.__ptr_) {} __tree_const_iterator(__non_const_iterator __p) : __ptr_(__p.__ptr_) {}
reference operator*() const {return __ptr_->__value_;} _LIBCPP_INLINE_VISIBILITY reference operator*() const {return __ptr_->__value_;}
pointer operator->() const {return &__ptr_->__value_;} _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return &__ptr_->__value_;}
_LIBCPP_INLINE_VISIBILITY
__tree_const_iterator& operator++() __tree_const_iterator& operator++()
{__ptr_ = static_cast<__node_pointer>(__tree_next(static_cast<__node_base_pointer>(__ptr_))); {__ptr_ = static_cast<__node_pointer>(__tree_next(static_cast<__node_base_pointer>(__ptr_)));
return *this;} return *this;}
_LIBCPP_INLINE_VISIBILITY
__tree_const_iterator operator++(int) __tree_const_iterator operator++(int)
{__tree_const_iterator __t(*this); ++(*this); return __t;} {__tree_const_iterator __t(*this); ++(*this); return __t;}
_LIBCPP_INLINE_VISIBILITY
__tree_const_iterator& operator--() __tree_const_iterator& operator--()
{__ptr_ = static_cast<__node_pointer>(__tree_prev(static_cast<__node_base_pointer>(__ptr_))); {__ptr_ = static_cast<__node_pointer>(__tree_prev(static_cast<__node_base_pointer>(__ptr_)));
return *this;} return *this;}
_LIBCPP_INLINE_VISIBILITY
__tree_const_iterator operator--(int) __tree_const_iterator operator--(int)
{__tree_const_iterator __t(*this); --(*this); return __t;} {__tree_const_iterator __t(*this); --(*this); return __t;}
friend bool operator==(const __tree_const_iterator& __x, const __tree_const_iterator& __y) friend _LIBCPP_INLINE_VISIBILITY
bool operator==(const __tree_const_iterator& __x, const __tree_const_iterator& __y)
{return __x.__ptr_ == __y.__ptr_;} {return __x.__ptr_ == __y.__ptr_;}
friend bool operator!=(const __tree_const_iterator& __x, const __tree_const_iterator& __y) friend _LIBCPP_INLINE_VISIBILITY
bool operator!=(const __tree_const_iterator& __x, const __tree_const_iterator& __y)
{return !(__x == __y);} {return !(__x == __y);}
private: private:
_LIBCPP_INLINE_VISIBILITY
explicit __tree_const_iterator(__node_pointer __p) : __ptr_(__p) {} explicit __tree_const_iterator(__node_pointer __p) : __ptr_(__p) {}
template <class, class, class> friend class __tree; template <class, class, class> friend class __tree;
template <class, class, class, class> friend class map; template <class, class, class, class> friend class _LIBCPP_VISIBLE map;
template <class, class, class, class> friend class multimap; template <class, class, class, class> friend class _LIBCPP_VISIBLE multimap;
template <class, class, class> friend class set; template <class, class, class> friend class _LIBCPP_VISIBLE set;
template <class, class, class> friend class multiset; template <class, class, class> friend class _LIBCPP_VISIBLE multiset;
template <class> friend class __map_const_iterator; template <class> friend class _LIBCPP_VISIBLE __map_const_iterator;
}; };
template <class _Tp, class _Compare, class _Allocator> template <class _Tp, class _Compare, class _Allocator>
@ -782,6 +803,7 @@ private:
__compressed_pair<size_type, value_compare> __pair3_; __compressed_pair<size_type, value_compare> __pair3_;
public: public:
_LIBCPP_INLINE_VISIBILITY
__node_pointer __end_node() __node_pointer __end_node()
{ {
return static_cast<__node_pointer> return static_cast<__node_pointer>
@ -789,6 +811,7 @@ public:
pointer_traits<__end_node_ptr>::pointer_to(__pair1_.first()) pointer_traits<__end_node_ptr>::pointer_to(__pair1_.first())
); );
} }
_LIBCPP_INLINE_VISIBILITY
__node_const_pointer __end_node() const __node_const_pointer __end_node() const
{ {
return static_cast<__node_const_pointer> return static_cast<__node_const_pointer>
@ -796,22 +819,33 @@ public:
pointer_traits<__end_node_const_ptr>::pointer_to(__pair1_.first()) pointer_traits<__end_node_const_ptr>::pointer_to(__pair1_.first())
); );
} }
_LIBCPP_INLINE_VISIBILITY
__node_allocator& __node_alloc() {return __pair1_.second();} __node_allocator& __node_alloc() {return __pair1_.second();}
private: private:
_LIBCPP_INLINE_VISIBILITY
const __node_allocator& __node_alloc() const {return __pair1_.second();} const __node_allocator& __node_alloc() const {return __pair1_.second();}
_LIBCPP_INLINE_VISIBILITY
__node_pointer& __begin_node() {return __begin_node_;} __node_pointer& __begin_node() {return __begin_node_;}
_LIBCPP_INLINE_VISIBILITY
const __node_pointer& __begin_node() const {return __begin_node_;} const __node_pointer& __begin_node() const {return __begin_node_;}
public: public:
_LIBCPP_INLINE_VISIBILITY
allocator_type __alloc() const {return allocator_type(__node_alloc());} allocator_type __alloc() const {return allocator_type(__node_alloc());}
private: private:
_LIBCPP_INLINE_VISIBILITY
size_type& size() {return __pair3_.first();} size_type& size() {return __pair3_.first();}
public: public:
_LIBCPP_INLINE_VISIBILITY
const size_type& size() const {return __pair3_.first();} const size_type& size() const {return __pair3_.first();}
_LIBCPP_INLINE_VISIBILITY
value_compare& value_comp() {return __pair3_.second();} value_compare& value_comp() {return __pair3_.second();}
_LIBCPP_INLINE_VISIBILITY
const value_compare& value_comp() const {return __pair3_.second();} const value_compare& value_comp() const {return __pair3_.second();}
public: public:
_LIBCPP_INLINE_VISIBILITY
__node_pointer __root() __node_pointer __root()
{return static_cast<__node_pointer> (__end_node()->__left_);} {return static_cast<__node_pointer> (__end_node()->__left_);}
_LIBCPP_INLINE_VISIBILITY
__node_const_pointer __root() const __node_const_pointer __root() const
{return static_cast<__node_const_pointer>(__end_node()->__left_);} {return static_cast<__node_const_pointer>(__end_node()->__left_);}
@ -835,11 +869,16 @@ public:
~__tree(); ~__tree();
_LIBCPP_INLINE_VISIBILITY
iterator begin() {return iterator(__begin_node());} iterator begin() {return iterator(__begin_node());}
_LIBCPP_INLINE_VISIBILITY
const_iterator begin() const {return const_iterator(__begin_node());} const_iterator begin() const {return const_iterator(__begin_node());}
_LIBCPP_INLINE_VISIBILITY
iterator end() {return iterator(__end_node());} iterator end() {return iterator(__end_node());}
_LIBCPP_INLINE_VISIBILITY
const_iterator end() const {return const_iterator(__end_node());} const_iterator end() const {return const_iterator(__end_node());}
_LIBCPP_INLINE_VISIBILITY
size_type max_size() const {return __node_traits::max_size(__node_alloc());} size_type max_size() const {return __node_traits::max_size(__node_alloc());}
void clear(); void clear();
@ -908,6 +947,7 @@ public:
size_type __count_multi(const _Key& __k) const; size_type __count_multi(const _Key& __k) const;
template <class _Key> template <class _Key>
_LIBCPP_INLINE_VISIBILITY
iterator lower_bound(const _Key& __v) iterator lower_bound(const _Key& __v)
{return __lower_bound(__v, __root(), __end_node());} {return __lower_bound(__v, __root(), __end_node());}
template <class _Key> template <class _Key>
@ -915,6 +955,7 @@ public:
__node_pointer __root, __node_pointer __root,
__node_pointer __result); __node_pointer __result);
template <class _Key> template <class _Key>
_LIBCPP_INLINE_VISIBILITY
const_iterator lower_bound(const _Key& __v) const const_iterator lower_bound(const _Key& __v) const
{return __lower_bound(__v, __root(), __end_node());} {return __lower_bound(__v, __root(), __end_node());}
template <class _Key> template <class _Key>
@ -922,6 +963,7 @@ public:
__node_const_pointer __root, __node_const_pointer __root,
__node_const_pointer __result) const; __node_const_pointer __result) const;
template <class _Key> template <class _Key>
_LIBCPP_INLINE_VISIBILITY
iterator upper_bound(const _Key& __v) iterator upper_bound(const _Key& __v)
{return __upper_bound(__v, __root(), __end_node());} {return __upper_bound(__v, __root(), __end_node());}
template <class _Key> template <class _Key>
@ -929,6 +971,7 @@ public:
__node_pointer __root, __node_pointer __root,
__node_pointer __result); __node_pointer __result);
template <class _Key> template <class _Key>
_LIBCPP_INLINE_VISIBILITY
const_iterator upper_bound(const _Key& __v) const const_iterator upper_bound(const _Key& __v) const
{return __upper_bound(__v, __root(), __end_node());} {return __upper_bound(__v, __root(), __end_node());}
template <class _Key> template <class _Key>
@ -978,33 +1021,42 @@ private:
void destroy(__node_pointer __nd); void destroy(__node_pointer __nd);
_LIBCPP_INLINE_VISIBILITY
void __copy_assign_alloc(const __tree& __t) void __copy_assign_alloc(const __tree& __t)
{__copy_assign_alloc(__t, integral_constant<bool, {__copy_assign_alloc(__t, integral_constant<bool,
__node_traits::propagate_on_container_copy_assignment::value>());} __node_traits::propagate_on_container_copy_assignment::value>());}
_LIBCPP_INLINE_VISIBILITY
void __copy_assign_alloc(const __tree& __t, true_type) void __copy_assign_alloc(const __tree& __t, true_type)
{__node_alloc() = __t.__node_alloc();} {__node_alloc() = __t.__node_alloc();}
_LIBCPP_INLINE_VISIBILITY
void __copy_assign_alloc(const __tree& __t, false_type) {} void __copy_assign_alloc(const __tree& __t, false_type) {}
void __move_assign(__tree& __t, false_type); void __move_assign(__tree& __t, false_type);
void __move_assign(__tree& __t, true_type); void __move_assign(__tree& __t, true_type);
_LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__tree& __t) void __move_assign_alloc(__tree& __t)
{__move_assign_alloc(__t, integral_constant<bool, {__move_assign_alloc(__t, integral_constant<bool,
__node_traits::propagate_on_container_move_assignment::value>());} __node_traits::propagate_on_container_move_assignment::value>());}
_LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__tree& __t, true_type) void __move_assign_alloc(__tree& __t, true_type)
{__node_alloc() = _STD::move(__t.__node_alloc());} {__node_alloc() = _STD::move(__t.__node_alloc());}
_LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__tree& __t, false_type) {} void __move_assign_alloc(__tree& __t, false_type) {}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(__node_allocator& __x, __node_allocator& __y) static void __swap_alloc(__node_allocator& __x, __node_allocator& __y)
{__swap_alloc(__x, __y, integral_constant<bool, {__swap_alloc(__x, __y, integral_constant<bool,
__node_traits::propagate_on_container_swap::value>());} __node_traits::propagate_on_container_swap::value>());}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(__node_allocator& __x, __node_allocator& __y, true_type) static void __swap_alloc(__node_allocator& __x, __node_allocator& __y, true_type)
{ {
using _STD::swap; using _STD::swap;
swap(__x, __y); swap(__x, __y);
} }
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(__node_allocator& __x, __node_allocator& __y, false_type) static void __swap_alloc(__node_allocator& __x, __node_allocator& __y, false_type)
{} {}

View File

@ -25,12 +25,12 @@
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp> class tuple_size; template <class _Tp> class _LIBCPP_VISIBLE tuple_size;
template <size_t _Ip, class _Tp> class tuple_element; template <size_t _Ip, class _Tp> class _LIBCPP_VISIBLE tuple_element;
template <class ..._Tp> class tuple; template <class ..._Tp> class _LIBCPP_VISIBLE tuple;
template <class _T1, class _T2> class pair; template <class _T1, class _T2> class _LIBCPP_VISIBLE pair;
template <class _Tp, size_t _Size> struct array; template <class _Tp, size_t _Size> struct _LIBCPP_VISIBLE array;
template <class _Tp> struct __tuple_like : false_type {}; template <class _Tp> struct __tuple_like : false_type {};
@ -96,7 +96,7 @@ struct __make_tuple_indices
template <class ..._Tp> struct __tuple_types {}; template <class ..._Tp> struct __tuple_types {};
template <size_t _Ip> template <size_t _Ip>
class tuple_element<_Ip, __tuple_types<>> class _LIBCPP_VISIBLE tuple_element<_Ip, __tuple_types<>>
{ {
public: public:
static_assert(_Ip == 0, "tuple_element index out of range"); static_assert(_Ip == 0, "tuple_element index out of range");
@ -104,21 +104,21 @@ public:
}; };
template <class _Hp, class ..._Tp> template <class _Hp, class ..._Tp>
class tuple_element<0, __tuple_types<_Hp, _Tp...>> class _LIBCPP_VISIBLE tuple_element<0, __tuple_types<_Hp, _Tp...>>
{ {
public: public:
typedef _Hp type; typedef _Hp type;
}; };
template <size_t _Ip, class _Hp, class ..._Tp> template <size_t _Ip, class _Hp, class ..._Tp>
class tuple_element<_Ip, __tuple_types<_Hp, _Tp...>> class _LIBCPP_VISIBLE tuple_element<_Ip, __tuple_types<_Hp, _Tp...>>
{ {
public: public:
typedef typename tuple_element<_Ip-1, __tuple_types<_Tp...>>::type type; typedef typename tuple_element<_Ip-1, __tuple_types<_Tp...>>::type type;
}; };
template <class ..._Tp> template <class ..._Tp>
class tuple_size<__tuple_types<_Tp...>> class _LIBCPP_VISIBLE tuple_size<__tuple_types<_Tp...>>
: public integral_constant<size_t, sizeof...(_Tp)> : public integral_constant<size_t, sizeof...(_Tp)>
{ {
}; };

View File

@ -17,8 +17,8 @@
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp> class tuple_size; template <class _Tp> class _LIBCPP_VISIBLE tuple_size;
template <size_t _Ip, class _Tp> class tuple_element; template <size_t _Ip, class _Tp> class _LIBCPP_VISIBLE tuple_element;
_LIBCPP_END_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD

View File

@ -115,7 +115,7 @@ template <int I, class T, size_t N> const T& get(const array<T, N>&);
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp, size_t _Size> template <class _Tp, size_t _Size>
struct array struct _LIBCPP_VISIBLE array
{ {
// types: // types:
typedef array __self; typedef array __self;
@ -134,8 +134,10 @@ struct array
value_type __elems_[_Size > 0 ? _Size : 1]; value_type __elems_[_Size > 0 ? _Size : 1];
// No explicit construct/copy/destroy for aggregate type // No explicit construct/copy/destroy for aggregate type
_LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u) {_STD::fill_n(__elems_, _Size, __u);} _LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u)
_LIBCPP_INLINE_VISIBILITY void swap(array& __a) {_STD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);} {_STD::fill_n(__elems_, _Size, __u);}
_LIBCPP_INLINE_VISIBILITY void swap(array& __a)
{_STD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
// iterators: // iterators:
_LIBCPP_INLINE_VISIBILITY iterator begin() {return iterator(__elems_);} _LIBCPP_INLINE_VISIBILITY iterator begin() {return iterator(__elems_);}
@ -256,20 +258,22 @@ swap(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
} }
template <class _Tp, size_t _Size> template <class _Tp, size_t _Size>
class tuple_size<array<_Tp, _Size> > : public integral_constant<size_t, _Size> {}; class _LIBCPP_VISIBLE tuple_size<array<_Tp, _Size> >
: public integral_constant<size_t, _Size> {};
template <class _Tp, size_t _Size> template <class _Tp, size_t _Size>
class tuple_size<const array<_Tp, _Size> > : public integral_constant<size_t, _Size> {}; class _LIBCPP_VISIBLE tuple_size<const array<_Tp, _Size> >
: public integral_constant<size_t, _Size> {};
template <size_t _Ip, class _Tp, size_t _Size> template <size_t _Ip, class _Tp, size_t _Size>
class tuple_element<_Ip, array<_Tp, _Size> > class _LIBCPP_VISIBLE tuple_element<_Ip, array<_Tp, _Size> >
{ {
public: public:
typedef _Tp type; typedef _Tp type;
}; };
template <size_t _Ip, class _Tp, size_t _Size> template <size_t _Ip, class _Tp, size_t _Size>
class tuple_element<_Ip, const array<_Tp, _Size> > class _LIBCPP_VISIBLE tuple_element<_Ip, const array<_Tp, _Size> >
{ {
public: public:
typedef const _Tp type; typedef const _Tp type;