summaryrefslogtreecommitdiffstats
path: root/libcxx/include/stack
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2011-06-04 22:09:19 +0000
committerHoward Hinnant <hhinnant@apple.com>2011-06-04 22:09:19 +0000
commitbd0c16007845678801199bd397d822b05b8ad2dd (patch)
treef99928da54aa1e6444648aa1bf1ae88947222fa2 /libcxx/include/stack
parentc2ed270c0f31ea8a7bcfbce431b4b3570bbc3b4d (diff)
downloadbcm5719-llvm-bd0c16007845678801199bd397d822b05b8ad2dd.tar.gz
bcm5719-llvm-bd0c16007845678801199bd397d822b05b8ad2dd.zip
noexcept for <stack>. This completes noexcept for Chapter 23 [containers].
llvm-svn: 132652
Diffstat (limited to 'libcxx/include/stack')
-rw-r--r--libcxx/include/stack49
1 files changed, 39 insertions, 10 deletions
diff --git a/libcxx/include/stack b/libcxx/include/stack
index c247d86457f..2e00700348b 100644
--- a/libcxx/include/stack
+++ b/libcxx/include/stack
@@ -31,14 +31,21 @@ protected:
container_type c;
public:
- explicit stack();
+ stack() = default;
+ ~stack() = default;
+
+ stack(const stack& q) = default;
+ stack(stack&& q) = default;
+
+ stack& operator=(const stack& q) = default;
+ stack& operator=(stack&& q) = default;
+
explicit stack(const container_type& c);
explicit stack(container_type&& c);
- stack(stack&& s);
- stack& operator=(stack&& s);
template <class Alloc> explicit stack(const Alloc& a);
template <class Alloc> stack(const container_type& c, const Alloc& a);
template <class Alloc> stack(container_type&& c, const Alloc& a);
+ template <class Alloc> stack(const stack& c, const Alloc& a);
template <class Alloc> stack(stack&& c, const Alloc& a);
bool empty() const;
@@ -51,7 +58,7 @@ public:
template <class... Args> void emplace(Args&&... args);
void pop();
- void swap(stack& c);
+ void swap(stack& c) noexcept(noexcept(swap(c, q.c)));
};
template <class T, class Container>
@@ -68,7 +75,8 @@ template <class T, class Container>
bool operator<=(const stack<T, Container>& x, const stack<T, Container>& y);
template <class T, class Container>
- void swap(stack<T, Container>& x, stack<T, Container>& y);
+ void swap(stack<T, Container>& x, stack<T, Container>& y)
+ noexcept(noexcept(x.swap(y)));
} // std
@@ -106,16 +114,35 @@ protected:
public:
_LIBCPP_INLINE_VISIBILITY
- stack() : c() {}
+ stack()
+ _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value)
+ : c() {}
+
_LIBCPP_INLINE_VISIBILITY
- explicit stack(const container_type& __c) : c(__c) {}
+ stack(const stack& __q) : c(__q.c) {}
+
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
- explicit stack(container_type&& __c) : c(_STD::move(__c)) {}
+ stack(stack&& __q)
+ _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value)
+ : c(_STD::move(__q.c)) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
_LIBCPP_INLINE_VISIBILITY
- stack(stack&& __s) : c(_STD::move(__s.c)) {}
+ stack& operator=(const stack& __q) {c = __q.c; return *this;}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ _LIBCPP_INLINE_VISIBILITY
+ stack& operator=(stack&& __q)
+ _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value)
+ {c = _STD::move(__q.c); return *this;}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
_LIBCPP_INLINE_VISIBILITY
- stack& operator=(stack&& __s) {c = _STD::move(__s.c); return *this;}
+ explicit stack(const container_type& __c) : c(__c) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ _LIBCPP_INLINE_VISIBILITY
+ explicit stack(container_type&& __c) : c(_STD::move(__c)) {}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
@@ -176,6 +203,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
void swap(stack& __s)
+ _NOEXCEPT_(__is_nothrow_swappable<container_type>::value)
{
using _STD::swap;
swap(c, __s.c);
@@ -244,6 +272,7 @@ template <class _Tp, class _Container>
inline _LIBCPP_INLINE_VISIBILITY
void
swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y)
+ _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
{
__x.swap(__y);
}
OpenPOWER on IntegriCloud