swap_noexcept.pass.cpp 739 B

12345678910111213141516171819202122232425262728293031
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is dual licensed under the MIT and the University of Illinois Open
  6. // Source Licenses. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // <stack>
  10. // void swap(stack& c)
  11. // noexcept(__is_nothrow_swappable<container_type>::value);
  12. // This tests a conforming extension
  13. #include <stack>
  14. #include <cassert>
  15. #include "../../../MoveOnly.h"
  16. int main()
  17. {
  18. #if __has_feature(cxx_noexcept)
  19. {
  20. typedef std::stack<MoveOnly> C;
  21. C c1, c2;
  22. static_assert(noexcept(swap(c1, c2)), "");
  23. }
  24. #endif
  25. }