brintos

brintos / llvm-project-archived public Read only

0
0
Text · 950 B · e2de773 Raw
30 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// Check that vector diagnoses an allocator which has to implement rebind with an appropriate error message10 11#include <vector>12 13class FooAllocator {14public:15  using value_type = int;16  FooAllocator()   = default;17 18  int* allocate(int num_objects);19 20  void deallocate(int* ptr, int num_objects);21 22  bool operator==(const FooAllocator&) const { return true; }23  bool operator!=(const FooAllocator&) const { return false; }24};25 26void func() {27  std::vector<int, FooAllocator>28      v; //expected-error-re@*:* {{static assertion failed {{.*}}This allocator has to implement rebind}}29}30