diff --git a/include/stack b/include/stack index c247d864..2e007003 100644 --- a/include/stack +++ b/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 explicit stack(const Alloc& a); template stack(const container_type& c, const Alloc& a); template stack(container_type&& c, const Alloc& a); + template stack(const stack& c, const Alloc& a); template stack(stack&& c, const Alloc& a); bool empty() const; @@ -51,7 +58,7 @@ public: template void emplace(Args&&... args); void pop(); - void swap(stack& c); + void swap(stack& c) noexcept(noexcept(swap(c, q.c))); }; template @@ -68,7 +75,8 @@ template bool operator<=(const stack& x, const stack& y); template - void swap(stack& x, stack& y); + void swap(stack& x, stack& y) + noexcept(noexcept(x.swap(y))); } // std @@ -106,16 +114,35 @@ protected: public: _LIBCPP_INLINE_VISIBILITY - stack() : c() {} + stack() + _NOEXCEPT_(is_nothrow_default_constructible::value) + : c() {} + + _LIBCPP_INLINE_VISIBILITY + stack(const stack& __q) : c(__q.c) {} + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY + stack(stack&& __q) + _NOEXCEPT_(is_nothrow_move_constructible::value) + : c(_STD::move(__q.c)) {} +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + + _LIBCPP_INLINE_VISIBILITY + 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::value) + {c = _STD::move(__q.c); return *this;} +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY 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)) {} - _LIBCPP_INLINE_VISIBILITY - stack(stack&& __s) : c(_STD::move(__s.c)) {} - _LIBCPP_INLINE_VISIBILITY - stack& operator=(stack&& __s) {c = _STD::move(__s.c); return *this;} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template _LIBCPP_INLINE_VISIBILITY @@ -176,6 +203,7 @@ public: _LIBCPP_INLINE_VISIBILITY void swap(stack& __s) + _NOEXCEPT_(__is_nothrow_swappable::value) { using _STD::swap; swap(c, __s.c); @@ -244,6 +272,7 @@ template inline _LIBCPP_INLINE_VISIBILITY void swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y) + _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { __x.swap(__y); } diff --git a/test/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp b/test/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp new file mode 100644 index 00000000..521d9567 --- /dev/null +++ b/test/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// stack() +// noexcept(is_nothrow_default_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "../../../MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::stack C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } +#endif +} diff --git a/test/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp b/test/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp new file mode 100644 index 00000000..c502012c --- /dev/null +++ b/test/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// ~stack() // implied noexcept; + +#include +#include + +#include "../../../MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::stack C; + static_assert(std::is_nothrow_destructible::value, ""); + } +#endif +} diff --git a/test/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp b/test/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp new file mode 100644 index 00000000..4952803d --- /dev/null +++ b/test/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// stack& operator=(stack&& c) +// noexcept(is_nothrow_move_assignable::value); + +// This tests a conforming extension + +#include +#include + +#include "../../../MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::stack C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } +#endif +} diff --git a/test/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp b/test/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp new file mode 100644 index 00000000..c9826834 --- /dev/null +++ b/test/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// stack(stack&&) +// noexcept(is_nothrow_move_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "../../../MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::stack C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } +#endif +} diff --git a/test/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp b/test/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp new file mode 100644 index 00000000..d0977f4e --- /dev/null +++ b/test/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(stack& c) +// noexcept(__is_nothrow_swappable::value); + +// This tests a conforming extension + +#include +#include + +#include "../../../MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::stack C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } +#endif +}