diff options
author | Howard Hinnant <hhinnant@apple.com> | 2011-06-03 16:20:53 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2011-06-03 16:20:53 +0000 |
commit | 91a4750733ce58a3098cc6d97ba897abdb4acb83 (patch) | |
tree | 2e0422a0fddd991f8312c44bcc29b089096b251b /libcxx/test/containers | |
parent | a4a59aebd922c117e8f684f4ac31594343679504 (diff) | |
download | bcm5719-llvm-91a4750733ce58a3098cc6d97ba897abdb4acb83.tar.gz bcm5719-llvm-91a4750733ce58a3098cc6d97ba897abdb4acb83.zip |
noexcept for <forward_list>.
llvm-svn: 132553
Diffstat (limited to 'libcxx/test/containers')
6 files changed, 268 insertions, 0 deletions
diff --git a/libcxx/test/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp b/libcxx/test/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp index 491e906b0a8..15e082e4557 100644 --- a/libcxx/test/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp +++ b/libcxx/test/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp @@ -17,6 +17,8 @@ #include "../../../MoveOnly.h" #include "../../../test_allocator.h" +#if __has_feature(cxx_noexcept) + template <class T> struct some_alloc { @@ -25,6 +27,8 @@ struct some_alloc ~some_alloc() noexcept(false); }; +#endif + int main() { #if __has_feature(cxx_noexcept) diff --git a/libcxx/test/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp b/libcxx/test/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp new file mode 100644 index 00000000000..2236048d038 --- /dev/null +++ b/libcxx/test/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <forward_list> + +// forward_list() +// noexcept(is_nothrow_default_constructible<allocator_type>::value); + +// This tests a conforming extension + +#include <forward_list> +#include <cassert> + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +template <class T> +struct some_alloc +{ + typedef T value_type; + some_alloc(const some_alloc&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::forward_list<MoveOnly> C; + static_assert(std::is_nothrow_default_constructible<C>::value, ""); + } + { + typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C; + static_assert(std::is_nothrow_default_constructible<C>::value, ""); + } + { + typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C; + static_assert(!std::is_nothrow_default_constructible<C>::value, ""); + } + { + typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C; + static_assert(!std::is_nothrow_default_constructible<C>::value, ""); + } +#endif +} diff --git a/libcxx/test/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp b/libcxx/test/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp new file mode 100644 index 00000000000..9f12ced1e33 --- /dev/null +++ b/libcxx/test/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <forward_list> + +// ~forward_list() // implied noexcept; + +#include <forward_list> +#include <cassert> + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +#if __has_feature(cxx_noexcept) + +template <class T> +struct some_alloc +{ + typedef T value_type; + some_alloc(const some_alloc&); + ~some_alloc() noexcept(false); +}; + +#endif + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::forward_list<MoveOnly> C; + static_assert(std::is_nothrow_destructible<C>::value, ""); + } + { + typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C; + static_assert(std::is_nothrow_destructible<C>::value, ""); + } + { + typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C; + static_assert(std::is_nothrow_destructible<C>::value, ""); + } + { + typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C; + static_assert(!std::is_nothrow_destructible<C>::value, ""); + } +#endif +} diff --git a/libcxx/test/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp b/libcxx/test/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp new file mode 100644 index 00000000000..b19e6dcfe39 --- /dev/null +++ b/libcxx/test/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <forward_list> + +// forward_list& operator=(forward_list&& c) +// noexcept( +// allocator_type::propagate_on_container_move_assignment::value && +// is_nothrow_move_assignable<allocator_type>::value); + +// This tests a conforming extension + +#include <forward_list> +#include <cassert> + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +template <class T> +struct some_alloc +{ + typedef T value_type; + some_alloc(const some_alloc&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::forward_list<MoveOnly> C; + static_assert(std::is_nothrow_move_assignable<C>::value, ""); + } + { + typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C; + static_assert(!std::is_nothrow_move_assignable<C>::value, ""); + } + { + typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C; + static_assert(std::is_nothrow_move_assignable<C>::value, ""); + } + { + typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C; + static_assert(!std::is_nothrow_move_assignable<C>::value, ""); + } +#endif +} diff --git a/libcxx/test/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp b/libcxx/test/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp new file mode 100644 index 00000000000..d3a3d523746 --- /dev/null +++ b/libcxx/test/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <forward_list> + +// forward_list(forward_list&&) +// noexcept(is_nothrow_move_constructible<allocator_type>::value); + +// This tests a conforming extension + +#include <forward_list> +#include <cassert> + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +template <class T> +struct some_alloc +{ + typedef T value_type; + some_alloc(const some_alloc&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::forward_list<MoveOnly> C; + static_assert(std::is_nothrow_move_constructible<C>::value, ""); + } + { + typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C; + static_assert(std::is_nothrow_move_constructible<C>::value, ""); + } + { + typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C; + static_assert(std::is_nothrow_move_constructible<C>::value, ""); + } + { + typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C; + static_assert(!std::is_nothrow_move_constructible<C>::value, ""); + } +#endif +} diff --git a/libcxx/test/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp b/libcxx/test/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp new file mode 100644 index 00000000000..777a6668882 --- /dev/null +++ b/libcxx/test/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp @@ -0,0 +1,60 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <forward_list> + +// void swap(forward_list& c) +// noexcept(!allocator_type::propagate_on_container_swap::value || +// __is_nothrow_swappable<allocator_type>::value); + +// This tests a conforming extension + +#include <forward_list> +#include <cassert> + +#include "../../../MoveOnly.h" +#include "../../../test_allocator.h" + +template <class T> +struct some_alloc +{ + typedef T value_type; + + some_alloc() {} + some_alloc(const some_alloc&); + void deallocate(void*, unsigned) {} + + typedef std::true_type propagate_on_container_swap; +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::forward_list<MoveOnly> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } +#endif +} |