194611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow//===----------------------------------------------------------------------===//
294611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow//
394611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow//                     The LLVM Compiler Infrastructure
494611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow//
594611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow// This file is dual licensed under the MIT and the University of Illinois Open
694611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow// Source Licenses. See LICENSE.TXT for details.
794611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow//
894611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow//===----------------------------------------------------------------------===//
994611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
1094611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow// type_traits
1194611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
1294611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow// is_array
1394611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
1494611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow#include <type_traits>
1584acb1ec3f7d5e0f37d7176697c2fa876c413407Eric Fiselier#include <cstddef>        // for std::nullptr_t
1694611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow#include "test_macros.h"
1794611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
1894611a888b69dabe99f8fe30867d0ebd78854759Marshall Clowtemplate <class T>
1994611a888b69dabe99f8fe30867d0ebd78854759Marshall Clowvoid test_is_array()
2094611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow{
2194611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert( std::is_array<T>::value, "");
2294611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert( std::is_array<const T>::value, "");
2394611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert( std::is_array<volatile T>::value, "");
2494611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert( std::is_array<const volatile T>::value, "");
2594611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow#if TEST_STD_VER > 14
2694611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert( std::is_array_v<T>, "");
2794611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert( std::is_array_v<const T>, "");
2894611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert( std::is_array_v<volatile T>, "");
2994611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert( std::is_array_v<const volatile T>, "");
3094611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow#endif
3194611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow}
3294611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
3394611a888b69dabe99f8fe30867d0ebd78854759Marshall Clowtemplate <class T>
3494611a888b69dabe99f8fe30867d0ebd78854759Marshall Clowvoid test_is_not_array()
3594611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow{
3694611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert(!std::is_array<T>::value, "");
3794611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert(!std::is_array<const T>::value, "");
3894611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert(!std::is_array<volatile T>::value, "");
3994611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert(!std::is_array<const volatile T>::value, "");
4094611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow#if TEST_STD_VER > 14
4194611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert(!std::is_array_v<T>, "");
4294611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert(!std::is_array_v<const T>, "");
4394611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert(!std::is_array_v<volatile T>, "");
4494611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert(!std::is_array_v<const volatile T>, "");
4594611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow#endif
4694611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow}
4794611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
4894611a888b69dabe99f8fe30867d0ebd78854759Marshall Clowclass Empty
4994611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow{
5094611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow};
5194611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
5294611a888b69dabe99f8fe30867d0ebd78854759Marshall Clowclass NotEmpty
5394611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow{
5494611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    virtual ~NotEmpty();
5594611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow};
5694611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
5794611a888b69dabe99f8fe30867d0ebd78854759Marshall Clowunion Union {};
5894611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
5994611a888b69dabe99f8fe30867d0ebd78854759Marshall Clowstruct bit_zero
6094611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow{
6194611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    int :  0;
6294611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow};
6394611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
6494611a888b69dabe99f8fe30867d0ebd78854759Marshall Clowclass Abstract
6594611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow{
6694611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    virtual ~Abstract() = 0;
6794611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow};
6894611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
6994611a888b69dabe99f8fe30867d0ebd78854759Marshall Clowenum Enum {zero, one};
707490f53118156f446b61583b7f0af0847b5942d7Marshall Clowstruct incomplete_type;
7194611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
7294611a888b69dabe99f8fe30867d0ebd78854759Marshall Clowtypedef void (*FunctionPtr)();
7394611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
7494611a888b69dabe99f8fe30867d0ebd78854759Marshall Clowint main()
7594611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow{
7694611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_array<char[3]>();
7794611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_array<char[]>();
7894611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_array<Union[]>();
7994611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
8094611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_array<std::nullptr_t>();
8194611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_array<void>();
8294611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_array<int&>();
8394611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_array<int&&>();
8494611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_array<int*>();
8594611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_array<double>();
8694611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_array<const int*>();
8794611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_array<Enum>();
8894611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_array<Union>();
8994611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_array<FunctionPtr>();
9094611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_array<Empty>();
9194611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_array<bit_zero>();
9294611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_array<NotEmpty>();
93211f9a485c4b13c61553d55a7bc662e1506b28fdMarshall Clow    test_is_not_array<incomplete_type>();  //  LWG#2582
9494611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow}
95