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// UNSUPPORTED: c++03, c++1110// <utility>11 12// template<class T, T... I>13// struct integer_sequence14// {15// typedef T type;16//17// static constexpr size_t size() noexcept;18// };19 20#include <utility>21#include <type_traits>22#include <cstddef>23#include <cassert>24 25#include "test_macros.h"26 27int main(int, char**)28{29// Make a few of sequences30 using int3 = std::integer_sequence<int, 3, 2, 1>;31 using size1 = std::integer_sequence<std::size_t, 7>;32 using ushort2 = std::integer_sequence<unsigned short, 4, 6>;33 using bool0 = std::integer_sequence<bool>;34 35// Make sure they're what we expect36 static_assert ( std::is_same<int3::value_type, int>::value, "int3 type wrong" );37 static_assert ( int3::size() == 3, "int3 size wrong" );38 39 static_assert ( std::is_same<size1::value_type, std::size_t>::value, "size1 type wrong" );40 static_assert ( size1::size() == 1, "size1 size wrong" );41 42 static_assert ( std::is_same<ushort2::value_type, unsigned short>::value, "ushort2 type wrong" );43 static_assert ( ushort2::size() == 2, "ushort2 size wrong" );44 45 static_assert ( std::is_same<bool0::value_type, bool>::value, "bool0 type wrong" );46 static_assert ( bool0::size() == 0, "bool0 size wrong" );47 48 return 0;49}50