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