brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.1 KiB · 415e9ee Raw
72 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_map>12 13// Test CTAD on cases where deduction should fail.14 15#include <array>16#include <flat_map>17#include <functional>18#include <tuple>19#include <utility>20 21struct NotAnAllocator {22  friend bool operator<(NotAnAllocator, NotAnAllocator) { return false; }23};24 25using P  = std::pair<int, long>;26using PC = std::pair<const int, long>;27 28void test() {29  {30    // cannot deduce that the inner braced things should be std::pair and not something else31    std::flat_multimap m{{1, 1L}, {2, 2L}, {3, 3L}};32    // expected-error-re@-1{{{{no viable constructor or deduction guide for deduction of template arguments of '.*flat_multimap'}}}}33  }34  {35    // cannot deduce that the inner braced things should be std::pair and not something else36    std::flat_multimap m({{1, 1L}, {2, 2L}, {3, 3L}}, std::less<int>());37    // expected-error-re@-1{{{{no viable constructor or deduction guide for deduction of template arguments of '.*flat_multimap'}}}}38  }39  {40    // cannot deduce that the inner braced things should be std::pair and not something else41    std::flat_multimap m({{1, 1L}, {2, 2L}, {3, 3L}}, std::less<int>(), std::allocator<PC>());42    // expected-error-re@-1{{{{no viable constructor or deduction guide for deduction of template arguments of '.*flat_multimap'}}}}43  }44  {45    // cannot deduce that the inner braced things should be std::pair and not something else46    std::flat_multimap m({{1, 1L}, {2, 2L}, {3, 3L}}, std::allocator<PC>());47    // expected-error-re@-1{{{{no viable constructor or deduction guide for deduction of template arguments of '.*flat_multimap'}}}}48  }49  {50    // since we have parens, not braces, this deliberately does not find the initializer_list constructor51    std::flat_multimap m(P{1, 1L});52    // expected-error-re@-1{{{{no viable constructor or deduction guide for deduction of template arguments of '.*flat_multimap'}}}}53  }54  {55    // since we have parens, not braces, this deliberately does not find the initializer_list constructor56    std::flat_multimap m(PC{1, 1L});57    // expected-error-re@-1{{{{no viable constructor or deduction guide for deduction of template arguments of '.*flat_multimap'}}}}58  }59  {60    // cannot deduce from tuple-like objects without proper iterator61    std::tuple<int, double> t{1, 2.0};62    std::flat_multimap m(t);63    // expected-error-re@-1{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}flat_multimap'}}64  }65  {66    // cannot deduce from array-like objects without proper iterator67    std::array<int, 2> arr{1, 2};68    std::flat_multimap m(arr);69    // expected-error-re@-1{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}flat_multimap'}}70  }71}72