1*bb075eebSJakub Mazurkiewicz //===----------------------------------------------------------------------===// 2*bb075eebSJakub Mazurkiewicz // 3*bb075eebSJakub Mazurkiewicz // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*bb075eebSJakub Mazurkiewicz // See https://llvm.org/LICENSE.txt for license information. 5*bb075eebSJakub Mazurkiewicz // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*bb075eebSJakub Mazurkiewicz // 7*bb075eebSJakub Mazurkiewicz //===----------------------------------------------------------------------===// 8*bb075eebSJakub Mazurkiewicz 9*bb075eebSJakub Mazurkiewicz // UNSUPPORTED: c++03, c++11, c++14, c++17 10*bb075eebSJakub Mazurkiewicz 11*bb075eebSJakub Mazurkiewicz // <array> 12*bb075eebSJakub Mazurkiewicz 13*bb075eebSJakub Mazurkiewicz // LWG-3382 NTTP for pair and array: 14*bb075eebSJakub Mazurkiewicz // array<T, N> is a structural type ([temp.param]) if T is a structural type. 15*bb075eebSJakub Mazurkiewicz 16*bb075eebSJakub Mazurkiewicz #include <array> 17*bb075eebSJakub Mazurkiewicz 18*bb075eebSJakub Mazurkiewicz #include <cstddef> 19*bb075eebSJakub Mazurkiewicz #include <string> 20*bb075eebSJakub Mazurkiewicz 21*bb075eebSJakub Mazurkiewicz struct LiteralBase {}; 22*bb075eebSJakub Mazurkiewicz struct LiteralNSDM {}; 23*bb075eebSJakub Mazurkiewicz 24*bb075eebSJakub Mazurkiewicz struct LiteralType : LiteralBase { 25*bb075eebSJakub Mazurkiewicz LiteralNSDM nsdm; 26*bb075eebSJakub Mazurkiewicz }; 27*bb075eebSJakub Mazurkiewicz 28*bb075eebSJakub Mazurkiewicz struct NotALiteral { NotALiteralNotALiteral29*bb075eebSJakub Mazurkiewicz NotALiteral() {} 30*bb075eebSJakub Mazurkiewicz }; 31*bb075eebSJakub Mazurkiewicz 32*bb075eebSJakub Mazurkiewicz int i; 33*bb075eebSJakub Mazurkiewicz NotALiteral not_a_literal; 34*bb075eebSJakub Mazurkiewicz 35*bb075eebSJakub Mazurkiewicz namespace test_full_type { 36*bb075eebSJakub Mazurkiewicz template <class T, std::size_t S, std::array<T, S> A> 37*bb075eebSJakub Mazurkiewicz struct test {}; 38*bb075eebSJakub Mazurkiewicz 39*bb075eebSJakub Mazurkiewicz using A = test<int, 2, std::array{2, 3}>; 40*bb075eebSJakub Mazurkiewicz using B = test<LiteralType, 0, std::array<LiteralType, 0>{}>; 41*bb075eebSJakub Mazurkiewicz using C = test<int*, 1, std::array<int*, 1>{&i}>; 42*bb075eebSJakub Mazurkiewicz using D = test<NotALiteral*, 1, std::array<NotALiteral*, 1>{¬_a_literal}>; 43*bb075eebSJakub Mazurkiewicz 44*bb075eebSJakub Mazurkiewicz using E = test<NotALiteral, 1, std::array<NotALiteral, 1>{}>; 45*bb075eebSJakub Mazurkiewicz // expected-error-re@*:* {{non-type template parameter has non-literal type 'std::array<NotALiteral, 1U{{L{0,2}.*}}>'}} 46*bb075eebSJakub Mazurkiewicz 47*bb075eebSJakub Mazurkiewicz using F = test<std::string, 2, std::array<std::string, 2>{}>; 48*bb075eebSJakub Mazurkiewicz // expected-error-re@*:* {{type 'std::array<{{(std::)?}}string, 2U{{L{0,2}.*}}>' {{(\(aka 'array<basic_string<char>, 2UL{0,2}>'\) )?}}of non-type template parameter is not a structural type}} 49*bb075eebSJakub Mazurkiewicz } // namespace test_full_type 50*bb075eebSJakub Mazurkiewicz 51*bb075eebSJakub Mazurkiewicz namespace test_ctad { 52*bb075eebSJakub Mazurkiewicz template <std::array A> 53*bb075eebSJakub Mazurkiewicz struct test {}; 54*bb075eebSJakub Mazurkiewicz 55*bb075eebSJakub Mazurkiewicz using A = test<std::array{2, 3}>; 56*bb075eebSJakub Mazurkiewicz using B = test<std::array<LiteralType, 0>{}>; 57*bb075eebSJakub Mazurkiewicz using C = test<std::array<int*, 1>{&i}>; 58*bb075eebSJakub Mazurkiewicz using D = test<std::array<NotALiteral*, 1>{¬_a_literal}>; 59*bb075eebSJakub Mazurkiewicz 60*bb075eebSJakub Mazurkiewicz using E = test<std::array<NotALiteral, 1>{}>; 61*bb075eebSJakub Mazurkiewicz // expected-error@-1 {{non-type template parameter has non-literal type 'std::array<NotALiteral, 1>'}} 62*bb075eebSJakub Mazurkiewicz 63*bb075eebSJakub Mazurkiewicz using F = test<std::array<std::string, 2>{}>; 64*bb075eebSJakub Mazurkiewicz // expected-error@-1 {{type 'std::array<string, 2>' (aka 'std::array<std::string, 2>') of non-type template parameter is not a structural type}} 65*bb075eebSJakub Mazurkiewicz } // namespace test_ctad 66*bb075eebSJakub Mazurkiewicz 67*bb075eebSJakub Mazurkiewicz namespace test_auto { 68*bb075eebSJakub Mazurkiewicz template <auto A> 69*bb075eebSJakub Mazurkiewicz struct test {}; 70*bb075eebSJakub Mazurkiewicz 71*bb075eebSJakub Mazurkiewicz using A = test<std::array{2, 3}>; 72*bb075eebSJakub Mazurkiewicz using B = test<std::array<LiteralType, 0>{}>; 73*bb075eebSJakub Mazurkiewicz using C = test<std::array<int*, 1>{&i}>; 74*bb075eebSJakub Mazurkiewicz using D = test<std::array<NotALiteral*, 1>{¬_a_literal}>; 75*bb075eebSJakub Mazurkiewicz 76*bb075eebSJakub Mazurkiewicz using E = test<std::array<NotALiteral, 1>{}>; 77*bb075eebSJakub Mazurkiewicz // expected-error@-1 {{non-type template parameter has non-literal type 'std::array<NotALiteral, 1>'}} 78*bb075eebSJakub Mazurkiewicz 79*bb075eebSJakub Mazurkiewicz using F = test<std::array<std::string, 2>{}>; 80*bb075eebSJakub Mazurkiewicz // expected-error@-1 {{type 'std::array<std::string, 2>' (aka 'array<basic_string<char>, 2>') of non-type template parameter is not a structural type}} 81*bb075eebSJakub Mazurkiewicz } // namespace test_auto 82