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
10// <vector>
11
12// vector(vector&&)
13//        noexcept(is_nothrow_move_constructible<allocator_type>::value);
14
15// This tests a conforming extension
16
17// UNSUPPORTED: c++98, c++03
18
19#include <vector>
20#include <cassert>
21
22#include "MoveOnly.h"
23#include "test_allocator.h"
24
25template <class T>
26struct some_alloc
27{
28    typedef T value_type;
29    some_alloc(const some_alloc&);
30};
31
32int main()
33{
34    {
35        typedef std::vector<MoveOnly> C;
36        static_assert(std::is_nothrow_move_constructible<C>::value, "");
37    }
38    {
39        typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C;
40        static_assert(std::is_nothrow_move_constructible<C>::value, "");
41    }
42    {
43        typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
44        static_assert(std::is_nothrow_move_constructible<C>::value, "");
45    }
46    {
47        typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
48    //  In C++17, move constructors for allocators are not allowed to throw
49#if TEST_STD_VER > 14
50        static_assert( std::is_nothrow_move_constructible<C>::value, "");
51#else
52        static_assert(!std::is_nothrow_move_constructible<C>::value, "");
53#endif
54    }
55}
56