brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · 6f0d802 Raw
68 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 <utility>19#include <tuple>20 21using P  = std::pair<int, long>;22using PC = std::pair<const int, long>;23 24void test() {25  {26    // cannot deduce that the inner braced things should be std::pair and not something else27    std::flat_map m{{1, 1L}, {2, 2L}, {3, 3L}};28    // expected-error-re@-1{{{{no viable constructor or deduction guide for deduction of template arguments of '.*flat_map'}}}}29  }30  {31    // cannot deduce that the inner braced things should be std::pair and not something else32    std::flat_map m({{1, 1L}, {2, 2L}, {3, 3L}}, std::less<int>());33    // expected-error-re@-1{{{{no viable constructor or deduction guide for deduction of template arguments of '.*flat_map'}}}}34  }35  {36    // cannot deduce that the inner braced things should be std::pair and not something else37    std::flat_map m({{1, 1L}, {2, 2L}, {3, 3L}}, std::less<int>(), std::allocator<PC>());38    // expected-error-re@-1{{{{no viable constructor or deduction guide for deduction of template arguments of '.*flat_map'}}}}39  }40  {41    // cannot deduce that the inner braced things should be std::pair and not something else42    std::flat_map m({{1, 1L}, {2, 2L}, {3, 3L}}, std::allocator<PC>());43    // expected-error-re@-1{{{{no viable constructor or deduction guide for deduction of template arguments of '.*flat_map'}}}}44  }45  {46    // since we have parens, not braces, this deliberately does not find the initializer_list constructor47    std::flat_map m(P{1, 1L});48    // expected-error-re@-1{{{{no viable constructor or deduction guide for deduction of template arguments of '.*flat_map'}}}}49  }50  {51    // since we have parens, not braces, this deliberately does not find the initializer_list constructor52    std::flat_map m(PC{1, 1L});53    // expected-error-re@-1{{{{no viable constructor or deduction guide for deduction of template arguments of '.*flat_map'}}}}54  }55  {56    // cannot deduce from tuple-like objects without proper iterator57    std::tuple<int, double> t{1, 2.0};58    std::flat_map m(t);59    // expected-error-re@-1{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}flat_map'}}60  }61  {62    // cannot deduce from array-like objects without proper iterator63    std::array<int, 2> arr{1, 2};64    std::flat_map m(arr);65    // expected-error-re@-1{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}flat_map'}}66  }67}68