xref: /llvm-project/libcxx/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp (revision 31cbe0f240f660f15602c96b787c58a26f17e179)
15a83710eSEric Fiselier //===----------------------------------------------------------------------===//
25a83710eSEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65a83710eSEric Fiselier //
75a83710eSEric Fiselier //===----------------------------------------------------------------------===//
85a83710eSEric Fiselier 
95a83710eSEric Fiselier // <vector>
105a83710eSEric Fiselier 
115a83710eSEric Fiselier // vector(vector&&)
125a83710eSEric Fiselier //        noexcept(is_nothrow_move_constructible<allocator_type>::value);
135a83710eSEric Fiselier 
145a83710eSEric Fiselier // This tests a conforming extension
155a83710eSEric Fiselier 
16*31cbe0f2SLouis Dionne // UNSUPPORTED: c++03
17f2f2a639SEric Fiselier 
185a83710eSEric Fiselier #include <vector>
195a83710eSEric Fiselier #include <cassert>
205a83710eSEric Fiselier 
21f950b851SEric Fiselier #include "test_macros.h"
225a83710eSEric Fiselier #include "test_allocator.h"
235a83710eSEric Fiselier 
245a83710eSEric Fiselier template <class T>
255a83710eSEric Fiselier struct some_alloc
265a83710eSEric Fiselier {
275a83710eSEric Fiselier     typedef T value_type;
285a83710eSEric Fiselier     some_alloc(const some_alloc&);
295a83710eSEric Fiselier };
305a83710eSEric Fiselier 
main(int,char **)312df59c50SJF Bastien int main(int, char**)
325a83710eSEric Fiselier {
3303fe6e2dSStephan T. Lavavej #if defined(_LIBCPP_VERSION)
345a83710eSEric Fiselier     {
355a83710eSEric Fiselier         typedef std::vector<bool> C;
3603fe6e2dSStephan T. Lavavej         static_assert(std::is_nothrow_move_constructible<C>::value, "");
375a83710eSEric Fiselier     }
385a83710eSEric Fiselier     {
395a83710eSEric Fiselier         typedef std::vector<bool, test_allocator<bool>> C;
4003fe6e2dSStephan T. Lavavej         static_assert(std::is_nothrow_move_constructible<C>::value, "");
415a83710eSEric Fiselier     }
425a83710eSEric Fiselier     {
435a83710eSEric Fiselier         typedef std::vector<bool, other_allocator<bool>> C;
4403fe6e2dSStephan T. Lavavej         static_assert(std::is_nothrow_move_constructible<C>::value, "");
455a83710eSEric Fiselier     }
4603fe6e2dSStephan T. Lavavej #endif // _LIBCPP_VERSION
475a83710eSEric Fiselier     {
4871ff7c3fSMarshall Clow     //  In C++17, move constructors for allocators are not allowed to throw
4971ff7c3fSMarshall Clow #if TEST_STD_VER > 14
5003fe6e2dSStephan T. Lavavej #if defined(_LIBCPP_VERSION)
5103fe6e2dSStephan T. Lavavej         typedef std::vector<bool, some_alloc<bool>> C;
5203fe6e2dSStephan T. Lavavej         static_assert( std::is_nothrow_move_constructible<C>::value, "");
5303fe6e2dSStephan T. Lavavej #endif // _LIBCPP_VERSION
5471ff7c3fSMarshall Clow #else
5503fe6e2dSStephan T. Lavavej         typedef std::vector<bool, some_alloc<bool>> C;
565a83710eSEric Fiselier         static_assert(!std::is_nothrow_move_constructible<C>::value, "");
5771ff7c3fSMarshall Clow #endif
585a83710eSEric Fiselier     }
592df59c50SJF Bastien 
602df59c50SJF Bastien   return 0;
615a83710eSEric Fiselier }
62