brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 6c2eecb Raw
56 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// type_traits10 11// rank12 13#include <type_traits>14 15#include "test_macros.h"16 17template <class T, unsigned A>18void test_rank()19{20    static_assert( std::rank<T>::value == A, "");21    static_assert( std::rank<const T>::value == A, "");22    static_assert( std::rank<volatile T>::value == A, "");23    static_assert( std::rank<const volatile T>::value == A, "");24#if TEST_STD_VER > 1425    static_assert( std::rank_v<T> == A, "");26    static_assert( std::rank_v<const T> == A, "");27    static_assert( std::rank_v<volatile T> == A, "");28    static_assert( std::rank_v<const volatile T> == A, "");29#endif30}31 32class Class33{34public:35    ~Class();36};37 38int main(int, char**)39{40    test_rank<void, 0>();41    test_rank<int&, 0>();42    test_rank<Class, 0>();43    test_rank<int*, 0>();44    test_rank<const int*, 0>();45    test_rank<int, 0>();46    test_rank<double, 0>();47    test_rank<bool, 0>();48    test_rank<unsigned, 0>();49 50    test_rank<char[3], 1>();51    test_rank<char[][3], 2>();52    test_rank<char[][4][3], 3>();53 54  return 0;55}56