62 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// UNSUPPORTED: c++03, c++11, c++14, c++179 10// <map>11 12// class map13 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 allocators25 {26 std::map<int, int, std::less<int>, std::allocator<int>> s1;27 std::map<int, int, std::less<int>, test_allocator<int>> s2;28 // expected-error-re@*:* {{static assertion failed due to requirement {{.+}}Allocator::value_type must be same type as value_type}}29 s1 <=> s2;30 // expected-error-re@*:* {{static assertion failed due to requirement {{.+}}Allocator::value_type must be same type as value_type}}31 s2 <=> s1;32 }33 // Mismatching comparision functions34 {35 std::map<int, int, std::less<int>> s1;36 std::map<int, int, std::greater<int>> s2;37 // expected-error@+1 {{invalid operands to binary expression}}38 s1 <=> s2;39 // expected-error@+1 {{invalid operands to binary expression}}40 s2 <=> s1;41 }42 {43 std::map<int, int, std::less<int>> s1;44 std::map<int, int, std::less<float>> s2;45 // expected-error@+1 {{invalid operands to binary expression}}46 s1 <=> s2;47 // expected-error@+1 {{invalid operands to binary expression}}48 s2 <=> s1;49 }50 // Mismatching types51 {52 std::map<int, int> s1;53 std::map<int, float> s2;54 // expected-error@+1 {{invalid operands to binary expression}}55 s1 <=> s2;56 // expected-error@+1 {{invalid operands to binary expression}}57 s2 <=> s1;58 }59 60 return 0;61}62