is_unsigned.pass.cpp
2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// type_traits
// is_unsigned
#include <type_traits>
#include "test_macros.h"
template <class T>
void test_is_unsigned()
{
static_assert( std::is_unsigned<T>::value, "");
static_assert( std::is_unsigned<const T>::value, "");
static_assert( std::is_unsigned<volatile T>::value, "");
static_assert( std::is_unsigned<const volatile T>::value, "");
#if TEST_STD_VER > 14
static_assert( std::is_unsigned_v<T>, "");
static_assert( std::is_unsigned_v<const T>, "");
static_assert( std::is_unsigned_v<volatile T>, "");
static_assert( std::is_unsigned_v<const volatile T>, "");
#endif
}
template <class T>
void test_is_not_unsigned()
{
static_assert(!std::is_unsigned<T>::value, "");
static_assert(!std::is_unsigned<const T>::value, "");
static_assert(!std::is_unsigned<volatile T>::value, "");
static_assert(!std::is_unsigned<const volatile T>::value, "");
#if TEST_STD_VER > 14
static_assert(!std::is_unsigned_v<T>, "");
static_assert(!std::is_unsigned_v<const T>, "");
static_assert(!std::is_unsigned_v<volatile T>, "");
static_assert(!std::is_unsigned_v<const volatile T>, "");
#endif
}
class Class
{
public:
~Class();
};
struct A; // incomplete
int main(int, char**)
{
test_is_not_unsigned<void>();
test_is_not_unsigned<int&>();
test_is_not_unsigned<Class>();
test_is_not_unsigned<int*>();
test_is_not_unsigned<const int*>();
test_is_not_unsigned<char[3]>();
test_is_not_unsigned<char[]>();
test_is_not_unsigned<int>();
test_is_not_unsigned<double>();
test_is_not_unsigned<A>();
test_is_unsigned<bool>();
test_is_unsigned<unsigned>();
#ifndef _LIBCPP_HAS_NO_INT128
test_is_unsigned<__uint128_t>();
test_is_not_unsigned<__int128_t>();
#endif
return 0;
}