llvm-project
61 строка · 2.1 Кб
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-exception
6//
7//===----------------------------------------------------------------------===//
8// UNSUPPORTED: c++03, c++11, c++14, c++17
9
10// <map>
11
12// class map
13
14// template<class Key, class T, class Compare, class Allocator>
15// synth-three-way-result<pair<const Key, T>>
16// operator<=>(const map<Key, T, Compare, Allocator>& x,
17// const map<Key, T, Compare, Allocator>& y);
18
19#include <map>
20
21#include "test_allocator.h"
22
23int main(int, char**) {
24// Mismatching allocators
25{
26std::map<int, int, std::less<int>, std::allocator<int>> s1;
27std::map<int, int, std::less<int>, test_allocator<int>> s2;
28// expected-error-re@*:* {{static assertion failed due to requirement 'is_same<int, std::pair<const int, int>>::value'{{.*}}Allocator::value_type must be same type as value_type}}
29s1 <=> s2;
30// expected-error-re@*:* {{static assertion failed due to requirement 'is_same<int, std::pair<const int, int>>::value'{{.*}}Allocator::value_type must be same type as value_type}}
31s2 <=> s1;
32}
33// Mismatching comparision functions
34{
35std::map<int, int, std::less<int>> s1;
36std::map<int, int, std::greater<int>> s2;
37// expected-error@+1 {{invalid operands to binary expression}}
38s1 <=> s2;
39// expected-error@+1 {{invalid operands to binary expression}}
40s2 <=> s1;
41}
42{
43std::map<int, int, std::less<int>> s1;
44std::map<int, int, std::less<float>> s2;
45// expected-error@+1 {{invalid operands to binary expression}}
46s1 <=> s2;
47// expected-error@+1 {{invalid operands to binary expression}}
48s2 <=> s1;
49}
50// Mismatching types
51{
52std::map<int, int> s1;
53std::map<int, float> s2;
54// expected-error@+1 {{invalid operands to binary expression}}
55s1 <=> s2;
56// expected-error@+1 {{invalid operands to binary expression}}
57s2 <=> s1;
58}
59
60return 0;
61}
62