brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 2426fbc Raw
79 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// UNSUPPORTED: c++03, c++11, c++14, c++17, c++2010 11// <flat_set>12 13// template<class Allocator>14//   explicit flat_multiset(const Allocator& a);15 16#include <cassert>17#include <deque>18#include <flat_set>19#include <functional>20#include <vector>21 22#include "test_macros.h"23#include "test_allocator.h"24#include "../../../test_compare.h"25 26template <template <class...> class KeyContainer>27constexpr void test() {28  {29    // The constructors in this subclause shall not participate in overload30    // resolution unless uses_allocator_v<container_type, Alloc> is true31 32    using C  = test_less<int>;33    using A1 = test_allocator<int>;34    using A2 = other_allocator<int>;35    using V1 = KeyContainer<int, A1>;36    using V2 = KeyContainer<int, A2>;37    using M1 = std::flat_multiset<int, C, V1>;38    using M2 = std::flat_multiset<int, C, V2>;39    static_assert(std::is_constructible_v<M1, const A1&>);40    static_assert(std::is_constructible_v<M2, const A2&>);41    static_assert(!std::is_constructible_v<M1, const A2&>);42    static_assert(!std::is_constructible_v<M2, const A1&>);43  }44  {45    using A = test_allocator<short>;46    using M = std::flat_multiset<int, std::less<int>, KeyContainer<int, test_allocator<int>>>;47    M m(A(0, 5));48    assert(m.empty());49    assert(m.begin() == m.end());50    assert(std::move(m).extract().get_allocator().get_id() == 5);51  }52  {53    // explicit54    using M = std::flat_multiset<int, std::less<int>, KeyContainer<int, test_allocator<int>>>;55 56    static_assert(std::is_constructible_v<M, test_allocator<int>>);57    static_assert(!std::is_convertible_v<test_allocator<int>, M>);58  }59}60 61constexpr bool test() {62  test<std::vector>();63#ifndef __cpp_lib_constexpr_deque64  if (!TEST_IS_CONSTANT_EVALUATED)65#endif66    test<std::deque>();67 68  return true;69}70 71int main(int, char**) {72  test();73#if TEST_STD_VER >= 2674  static_assert(test());75#endif76 77  return 0;78}79