diff options
author | dim <dim@FreeBSD.org> | 2013-04-27 22:47:52 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2013-04-27 22:47:52 +0000 |
commit | 815a6cc1e325a4e8596b91756039a7d699471b11 (patch) | |
tree | e5a6a26d0973c6968273f6fabb61cb3d624be555 /contrib/libc++/include/memory | |
parent | 1497a98f71419ff66d08ad2b8c90530e65521ac2 (diff) | |
download | FreeBSD-src-815a6cc1e325a4e8596b91756039a7d699471b11.zip FreeBSD-src-815a6cc1e325a4e8596b91756039a7d699471b11.tar.gz |
Merge libc++ trunk r180598. Contains several minor cleanups and bug
fixes, no major changes.
MFC after: 2 weeks
Diffstat (limited to 'contrib/libc++/include/memory')
-rw-r--r-- | contrib/libc++/include/memory | 75 |
1 files changed, 40 insertions, 35 deletions
diff --git a/contrib/libc++/include/memory b/contrib/libc++/include/memory index f80d699..2a8b7e6 100644 --- a/contrib/libc++/include/memory +++ b/contrib/libc++/include/memory @@ -621,7 +621,7 @@ inline _LIBCPP_INLINE_VISIBILITY _Tp* addressof(_Tp& __x) _NOEXCEPT { - return (_Tp*)&(char&)__x; + return (_Tp*)&reinterpret_cast<const volatile char&>(__x); } #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF) @@ -667,7 +667,7 @@ addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT template <class _Tp> class allocator; template <> -class _LIBCPP_VISIBLE allocator<void> +class _LIBCPP_TYPE_VIS allocator<void> { public: typedef void* pointer; @@ -678,7 +678,7 @@ public: }; template <> -class _LIBCPP_VISIBLE allocator<const void> +class _LIBCPP_TYPE_VIS allocator<const void> { public: typedef const void* pointer; @@ -913,7 +913,7 @@ struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, false> #endif // _LIBCPP_HAS_NO_VARIADICS template <class _Ptr> -struct _LIBCPP_VISIBLE pointer_traits +struct _LIBCPP_TYPE_VIS pointer_traits { typedef _Ptr pointer; typedef typename __pointer_traits_element_type<pointer>::type element_type; @@ -936,7 +936,7 @@ public: }; template <class _Tp> -struct _LIBCPP_VISIBLE pointer_traits<_Tp*> +struct _LIBCPP_TYPE_VIS pointer_traits<_Tp*> { typedef _Tp* pointer; typedef _Tp element_type; @@ -1443,7 +1443,7 @@ struct __alloc_traits_difference_type<_Alloc, _Ptr, true> }; template <class _Alloc> -struct _LIBCPP_VISIBLE allocator_traits +struct _LIBCPP_TYPE_VIS allocator_traits { typedef _Alloc allocator_type; typedef typename allocator_type::value_type value_type; @@ -1649,7 +1649,7 @@ private: // allocator template <class _Tp> -class _LIBCPP_VISIBLE allocator +class _LIBCPP_TYPE_VIS allocator { public: typedef size_t size_type; @@ -1741,7 +1741,7 @@ public: }; template <class _Tp> -class _LIBCPP_VISIBLE allocator<const _Tp> +class _LIBCPP_TYPE_VIS allocator<const _Tp> { public: typedef size_t size_type; @@ -1839,7 +1839,7 @@ inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;} template <class _OutputIterator, class _Tp> -class _LIBCPP_VISIBLE raw_storage_iterator +class _LIBCPP_TYPE_VIS raw_storage_iterator : public iterator<output_iterator_tag, _Tp, // purposefully not C++03 ptrdiff_t, // purposefully not C++03 @@ -1892,7 +1892,7 @@ struct auto_ptr_ref }; template<class _Tp> -class _LIBCPP_VISIBLE auto_ptr +class _LIBCPP_TYPE_VIS auto_ptr { private: _Tp* __ptr_; @@ -1936,7 +1936,7 @@ public: }; template <> -class _LIBCPP_VISIBLE auto_ptr<void> +class _LIBCPP_TYPE_VIS auto_ptr<void> { public: typedef void element_type; @@ -2472,7 +2472,7 @@ struct __same_or_less_cv_qualified<_Ptr1, _Ptr2, true> // default_delete template <class _Tp> -struct _LIBCPP_VISIBLE default_delete +struct _LIBCPP_TYPE_VIS default_delete { #ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default; @@ -2485,12 +2485,13 @@ struct _LIBCPP_VISIBLE default_delete _LIBCPP_INLINE_VISIBILITY void operator() (_Tp* __ptr) const _NOEXCEPT { static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type"); + static_assert(!is_void<_Tp>::value, "default_delete can not delete incomplete type"); delete __ptr; } }; template <class _Tp> -struct _LIBCPP_VISIBLE default_delete<_Tp[]> +struct _LIBCPP_TYPE_VIS default_delete<_Tp[]> { public: #ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS @@ -2507,12 +2508,13 @@ public: typename enable_if<__same_or_less_cv_qualified<_Up*, _Tp*>::value>::type* = 0) const _NOEXCEPT { static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type"); + static_assert(!is_void<_Tp>::value, "default_delete can not delete incomplete type"); delete [] __ptr; } }; template <class _Tp, class _Dp = default_delete<_Tp> > -class _LIBCPP_VISIBLE unique_ptr +class _LIBCPP_TYPE_VIS unique_ptr { public: typedef _Tp element_type; @@ -2691,7 +2693,7 @@ public: }; template <class _Tp, class _Dp> -class _LIBCPP_VISIBLE unique_ptr<_Tp[], _Dp> +class _LIBCPP_TYPE_VIS unique_ptr<_Tp[], _Dp> { public: typedef _Tp element_type; @@ -3393,7 +3395,7 @@ struct __scalar_hash<_Tp, 4> }; template<class _Tp> -struct _LIBCPP_VISIBLE hash<_Tp*> +struct _LIBCPP_TYPE_VIS hash<_Tp*> : public unary_function<_Tp*, size_t> { _LIBCPP_INLINE_VISIBILITY @@ -3410,7 +3412,7 @@ struct _LIBCPP_VISIBLE hash<_Tp*> }; template <class _Tp, class _Dp> -struct _LIBCPP_VISIBLE hash<unique_ptr<_Tp, _Dp> > +struct _LIBCPP_TYPE_VIS hash<unique_ptr<_Tp, _Dp> > { typedef unique_ptr<_Tp, _Dp> argument_type; typedef size_t result_type; @@ -3583,7 +3585,7 @@ public: virtual const char* what() const _NOEXCEPT; }; -template<class _Tp> class _LIBCPP_VISIBLE weak_ptr; +template<class _Tp> class _LIBCPP_TYPE_VIS weak_ptr; class __shared_count { @@ -3629,10 +3631,13 @@ public: long use_count() const _NOEXCEPT {return __shared_count::use_count();} __shared_weak_count* lock() _NOEXCEPT; - // purposefully not protected with #ifndef _LIBCPP_NO_RTTI because doing so - // breaks ABI for those clients who need to compile their projects with - // -fno-rtti and yet link against a libc++.dylib compiled without -fno-rtti. + // Define the function out only if we build static libc++ without RTTI. + // Otherwise we may break clients who need to compile their projects with + // -fno-rtti and yet link against a libc++.dylib compiled + // without -fno-rtti. +#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC) virtual const void* __get_deleter(const type_info&) const _NOEXCEPT; +#endif private: virtual void __on_zero_shared_weak() _NOEXCEPT = 0; }; @@ -3749,10 +3754,10 @@ __shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT __a.deallocate(this, 1); } -template<class _Tp> class _LIBCPP_VISIBLE enable_shared_from_this; +template<class _Tp> class _LIBCPP_TYPE_VIS enable_shared_from_this; template<class _Tp> -class _LIBCPP_VISIBLE shared_ptr +class _LIBCPP_TYPE_VIS shared_ptr { public: typedef _Tp element_type; @@ -4021,8 +4026,8 @@ private: _LIBCPP_INLINE_VISIBILITY void __enable_weak_this(const void*) _NOEXCEPT {} - template <class _Up> friend class _LIBCPP_VISIBLE shared_ptr; - template <class _Up> friend class _LIBCPP_VISIBLE weak_ptr; + template <class _Up> friend class _LIBCPP_TYPE_VIS shared_ptr; + template <class _Up> friend class _LIBCPP_TYPE_VIS weak_ptr; }; template<class _Tp> @@ -4918,7 +4923,7 @@ get_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT #endif // _LIBCPP_NO_RTTI template<class _Tp> -class _LIBCPP_VISIBLE weak_ptr +class _LIBCPP_TYPE_VIS weak_ptr { public: typedef _Tp element_type; @@ -4993,8 +4998,8 @@ public: bool owner_before(const weak_ptr<_Up>& __r) const {return __cntrl_ < __r.__cntrl_;} - template <class _Up> friend class _LIBCPP_VISIBLE weak_ptr; - template <class _Up> friend class _LIBCPP_VISIBLE shared_ptr; + template <class _Up> friend class _LIBCPP_TYPE_VIS weak_ptr; + template <class _Up> friend class _LIBCPP_TYPE_VIS shared_ptr; }; template<class _Tp> @@ -5194,7 +5199,7 @@ weak_ptr<_Tp>::lock() const _NOEXCEPT template <class _Tp> struct owner_less; template <class _Tp> -struct _LIBCPP_VISIBLE owner_less<shared_ptr<_Tp> > +struct _LIBCPP_TYPE_VIS owner_less<shared_ptr<_Tp> > : binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool> { typedef bool result_type; @@ -5210,7 +5215,7 @@ struct _LIBCPP_VISIBLE owner_less<shared_ptr<_Tp> > }; template <class _Tp> -struct _LIBCPP_VISIBLE owner_less<weak_ptr<_Tp> > +struct _LIBCPP_TYPE_VIS owner_less<weak_ptr<_Tp> > : binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool> { typedef bool result_type; @@ -5226,7 +5231,7 @@ struct _LIBCPP_VISIBLE owner_less<weak_ptr<_Tp> > }; template<class _Tp> -class _LIBCPP_VISIBLE enable_shared_from_this +class _LIBCPP_TYPE_VIS enable_shared_from_this { mutable weak_ptr<_Tp> __weak_this_; protected: @@ -5251,7 +5256,7 @@ public: }; template <class _Tp> -struct _LIBCPP_VISIBLE hash<shared_ptr<_Tp> > +struct _LIBCPP_TYPE_VIS hash<shared_ptr<_Tp> > { typedef shared_ptr<_Tp> argument_type; typedef size_t result_type; @@ -5281,10 +5286,10 @@ private: __sp_mut(const __sp_mut&); __sp_mut& operator=(const __sp_mut&); - friend _LIBCPP_VISIBLE __sp_mut& __get_sp_mut(const void*); + friend _LIBCPP_FUNC_VIS __sp_mut& __get_sp_mut(const void*); }; -_LIBCPP_VISIBLE __sp_mut& __get_sp_mut(const void*); +_LIBCPP_FUNC_VIS __sp_mut& __get_sp_mut(const void*); template <class _Tp> inline _LIBCPP_INLINE_VISIBILITY @@ -5396,7 +5401,7 @@ atomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v #endif // __has_feature(cxx_atomic) //enum class -struct _LIBCPP_VISIBLE pointer_safety +struct _LIBCPP_TYPE_VIS pointer_safety { enum __lx { |