noexcept for <array>.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@132359 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant 2011-05-31 21:06:33 +00:00
parent 20eda8b563
commit f0562af9dd
2 changed files with 65 additions and 46 deletions

View File

@ -102,15 +102,15 @@ get(pair<_T1, _T2>&&) _NOEXCEPT;
template <size_t _Ip, class _Tp, size_t _Size>
_Tp&
get(array<_Tp, _Size>&);
get(array<_Tp, _Size>&) _NOEXCEPT;
template <size_t _Ip, class _Tp, size_t _Size>
const _Tp&
get(const array<_Tp, _Size>&);
get(const array<_Tp, _Size>&) _NOEXCEPT;
template <size_t _Ip, class _Tp, size_t _Size>
_Tp&&
get(array<_Tp, _Size>&&);
get(array<_Tp, _Size>&&) _NOEXCEPT;
// __make_tuple_indices

View File

@ -34,28 +34,28 @@ struct array
// No explicit construct/copy/destroy for aggregate type
void fill(const T& u);
void swap(array& a);
void swap(array& a) noexcept(noexcept(swap(declval<T&>(), declval<T&>())));
// iterators:
iterator begin();
const_iterator begin() const;
iterator end();
const_iterator end() const;
iterator begin() noexcept;
const_iterator begin() const noexcept;
iterator end() noexcept;
const_iterator end() const noexcept;
reverse_iterator rbegin();
const_reverse_iterator rbegin() const;
reverse_iterator rend();
const_reverse_iterator rend() const;
reverse_iterator rbegin() noexcept;
const_reverse_iterator rbegin() const noexcept;
reverse_iterator rend() noexcept;
const_reverse_iterator rend() const noexcept;
const_iterator cbegin() const;
const_iterator cend() const;
const_reverse_iterator crbegin() const;
const_reverse_iterator crend() const;
const_iterator cbegin() const noexcept;
const_iterator cend() const noexcept;
const_reverse_iterator crbegin() const noexcept;
const_reverse_iterator crend() const noexcept;
// capacity:
constexpr size_type size() const;
constexpr size_type max_size() const;
bool empty() const;
constexpr size_type size() const noexcept;
constexpr size_type max_size() const noexcept;
bool empty() const noexcept;
// element access:
reference operator[](size_type n);
@ -68,8 +68,8 @@ struct array
reference back();
const_reference back() const;
T* data();
const T* data() const;
T* data() noexcept;
const T* data() const noexcept;
};
template <class T, size_t N>
@ -86,15 +86,15 @@ template <class T, size_t N>
bool operator>=(const array<T,N>& x, const array<T,N>& y);
template <class T, size_t N >
void swap(array<T,N>& x, array<T,N>& y);
void swap(array<T,N>& x, array<T,N>& y) noexcept(noexcept(x.swap(y)));
template <class T> class tuple_size;
template <int I, class T> class tuple_element;
template <class T, size_t N> struct tuple_size<array<T, N>>;
template <int I, class T, size_t N> struct tuple_element<I, array<T, N>>;
template <int I, class T, size_t N> T& get(array<T, N>&);
template <int I, class T, size_t N> const T& get(const array<T, N>&);
template <int I, class T, size_t N> T&& get(array<T, N>&&);
template <int I, class T, size_t N> T& get(array<T, N>&) noexcept;
template <int I, class T, size_t N> const T& get(const array<T, N>&) noexcept;
template <int I, class T, size_t N> T&& get(array<T, N>&&) noexcept;
} // std
@ -137,29 +137,45 @@ struct _LIBCPP_VISIBLE array
// 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 swap(array& __a)
_LIBCPP_INLINE_VISIBILITY
void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
{_STD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
// iterators:
_LIBCPP_INLINE_VISIBILITY iterator begin() {return iterator(__elems_);}
_LIBCPP_INLINE_VISIBILITY const_iterator begin() const {return const_iterator(__elems_);}
_LIBCPP_INLINE_VISIBILITY iterator end() {return iterator(__elems_ + _Size);}
_LIBCPP_INLINE_VISIBILITY const_iterator end() const {return const_iterator(__elems_ + _Size);}
_LIBCPP_INLINE_VISIBILITY
iterator begin() _NOEXCEPT {return iterator(__elems_);}
_LIBCPP_INLINE_VISIBILITY
const_iterator begin() const _NOEXCEPT {return const_iterator(__elems_);}
_LIBCPP_INLINE_VISIBILITY
iterator end() _NOEXCEPT {return iterator(__elems_ + _Size);}
_LIBCPP_INLINE_VISIBILITY
const_iterator end() const _NOEXCEPT {return const_iterator(__elems_ + _Size);}
_LIBCPP_INLINE_VISIBILITY reverse_iterator rbegin() {return reverse_iterator(end());}
_LIBCPP_INLINE_VISIBILITY const_reverse_iterator rbegin() const {return const_reverse_iterator(end());}
_LIBCPP_INLINE_VISIBILITY reverse_iterator rend() {return reverse_iterator(begin());}
_LIBCPP_INLINE_VISIBILITY const_reverse_iterator rend() const {return const_reverse_iterator(begin());}
_LIBCPP_INLINE_VISIBILITY
reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
_LIBCPP_INLINE_VISIBILITY
const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
_LIBCPP_INLINE_VISIBILITY
reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
_LIBCPP_INLINE_VISIBILITY
const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
_LIBCPP_INLINE_VISIBILITY const_iterator cbegin() const {return begin();}
_LIBCPP_INLINE_VISIBILITY const_iterator cend() const {return end();}
_LIBCPP_INLINE_VISIBILITY const_reverse_iterator crbegin() const {return rbegin();}
_LIBCPP_INLINE_VISIBILITY const_reverse_iterator crend() const {return rend();}
_LIBCPP_INLINE_VISIBILITY
const_iterator cbegin() const _NOEXCEPT {return begin();}
_LIBCPP_INLINE_VISIBILITY
const_iterator cend() const _NOEXCEPT {return end();}
_LIBCPP_INLINE_VISIBILITY
const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
_LIBCPP_INLINE_VISIBILITY
const_reverse_iterator crend() const _NOEXCEPT {return rend();}
// capacity:
_LIBCPP_INLINE_VISIBILITY /*constexpr*/ size_type size() const {return _Size;}
_LIBCPP_INLINE_VISIBILITY /*constexpr*/ size_type max_size() const {return _Size;}
_LIBCPP_INLINE_VISIBILITY bool empty() const {return _Size == 0;}
_LIBCPP_INLINE_VISIBILITY
/*constexpr*/ size_type size() const _NOEXCEPT {return _Size;}
_LIBCPP_INLINE_VISIBILITY
/*constexpr*/ size_type max_size() const _NOEXCEPT {return _Size;}
_LIBCPP_INLINE_VISIBILITY
bool empty() const _NOEXCEPT {return _Size == 0;}
// element access:
_LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) {return __elems_[__n];}
@ -172,8 +188,10 @@ struct _LIBCPP_VISIBLE array
_LIBCPP_INLINE_VISIBILITY reference back() {return __elems_[_Size > 0 ? _Size-1 : 0];}
_LIBCPP_INLINE_VISIBILITY const_reference back() const {return __elems_[_Size > 0 ? _Size-1 : 0];}
_LIBCPP_INLINE_VISIBILITY value_type* data() {return __elems_;}
_LIBCPP_INLINE_VISIBILITY const value_type* data() const {return __elems_;}
_LIBCPP_INLINE_VISIBILITY
value_type* data() _NOEXCEPT {return __elems_;}
_LIBCPP_INLINE_VISIBILITY
const value_type* data() const _NOEXCEPT {return __elems_;}
};
template <class _Tp, size_t _Size>
@ -254,6 +272,7 @@ template <class _Tp, size_t _Size>
_LIBCPP_INLINE_VISIBILITY inline
void
swap(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
_NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
{
__x.swap(__y);
}
@ -283,7 +302,7 @@ public:
template <size_t _Ip, class _Tp, size_t _Size>
_LIBCPP_INLINE_VISIBILITY inline
_Tp&
get(array<_Tp, _Size>& __a)
get(array<_Tp, _Size>& __a) _NOEXCEPT
{
return __a[_Ip];
}
@ -291,7 +310,7 @@ get(array<_Tp, _Size>& __a)
template <size_t _Ip, class _Tp, size_t _Size>
_LIBCPP_INLINE_VISIBILITY inline
const _Tp&
get(const array<_Tp, _Size>& __a)
get(const array<_Tp, _Size>& __a) _NOEXCEPT
{
return __a[_Ip];
}
@ -301,7 +320,7 @@ get(const array<_Tp, _Size>& __a)
template <size_t _Ip, class _Tp, size_t _Size>
_LIBCPP_INLINE_VISIBILITY inline
_Tp&&
get(array<_Tp, _Size>&& __a)
get(array<_Tp, _Size>&& __a) _NOEXCEPT
{
return _STD::move(__a[_Ip]);
}