brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · e5add73 Raw
100 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// <vector>10 11// vector& operator=(vector&& c)12//     noexcept(13//          allocator_type::propagate_on_container_move_assignment::value &&14//          is_nothrow_move_assignable<allocator_type>::value);15 16// This tests a conforming extension17 18// UNSUPPORTED: c++0319 20#include <cassert>21#include <vector>22#include <type_traits>23 24#include "test_macros.h"25#include "test_allocator.h"26 27template <class T>28struct some_alloc {29  typedef T value_type;30  some_alloc(const some_alloc&);31};32 33template <class T>34struct some_alloc2 {35  typedef T value_type;36 37  some_alloc2() {}38  some_alloc2(const some_alloc2&);39  void deallocate(void*, unsigned) {}40 41  typedef std::false_type propagate_on_container_move_assignment;42  typedef std::true_type is_always_equal;43};44 45template <class T>46struct some_alloc3 {47  typedef T value_type;48 49  some_alloc3() {}50  some_alloc3(const some_alloc3&);51  void deallocate(void*, unsigned) {}52 53  typedef std::false_type propagate_on_container_move_assignment;54  typedef std::false_type is_always_equal;55};56 57int main(int, char**) {58#if defined(_LIBCPP_VERSION)59  {60    typedef std::vector<bool> C;61    static_assert(std::is_nothrow_move_assignable<C>::value, "");62  }63#endif // _LIBCPP_VERSION64  {65    typedef std::vector<bool, test_allocator<bool>> C;66    static_assert(!std::is_nothrow_move_assignable<C>::value, "");67  }68#if defined(_LIBCPP_VERSION)69  {70    typedef std::vector<bool, other_allocator<bool>> C;71    static_assert(std::is_nothrow_move_assignable<C>::value, "");72  }73#endif // _LIBCPP_VERSION74  {75#if TEST_STD_VER > 1476#  if defined(_LIBCPP_VERSION)77    typedef std::vector<bool, some_alloc<bool>> C;78    static_assert(std::is_nothrow_move_assignable<C>::value, "");79#  endif // _LIBCPP_VERSION80#else81    typedef std::vector<bool, some_alloc<bool>> C;82    static_assert(!std::is_nothrow_move_assignable<C>::value, "");83#endif84  }85#if TEST_STD_VER > 1486#  if defined(_LIBCPP_VERSION)87  { // POCMA false, is_always_equal true88    typedef std::vector<bool, some_alloc2<bool>> C;89    static_assert(std::is_nothrow_move_assignable<C>::value, "");90  }91#  endif // _LIBCPP_VERSION92  {      // POCMA false, is_always_equal false93    typedef std::vector<bool, some_alloc3<bool>> C;94    static_assert(!std::is_nothrow_move_assignable<C>::value, "");95  }96#endif97 98  return 0;99}100