brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 582c9a5 Raw
50 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// Make sure std::array is an aggregate type.10// We can only check this in C++17 and above, because we don't have the11// trait before that.12// UNSUPPORTED: c++03, c++11, c++1413 14#include <array>15#include <type_traits>16 17template <typename T>18void check_aggregate() {19  static_assert(std::is_aggregate<std::array<T, 0> >::value, "");20  static_assert(std::is_aggregate<std::array<T, 1> >::value, "");21  static_assert(std::is_aggregate<std::array<T, 2> >::value, "");22  static_assert(std::is_aggregate<std::array<T, 3> >::value, "");23  static_assert(std::is_aggregate<std::array<T, 4> >::value, "");24}25 26struct Empty {};27struct Trivial {28  int i;29  int j;30};31struct NonTrivial {32  int i;33  int j;34  NonTrivial(NonTrivial const&) {}35};36 37int main(int, char**) {38  check_aggregate<char>();39  check_aggregate<int>();40  check_aggregate<long>();41  check_aggregate<float>();42  check_aggregate<double>();43  check_aggregate<long double>();44  check_aggregate<Empty>();45  check_aggregate<Trivial>();46  check_aggregate<NonTrivial>();47 48  return 0;49}50