Implement the first part of P0006R0: Adopt Type Traits Variable Templates for C++17. Significantly augment the existing tests.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@251766 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// type_traits
|
||||
|
||||
// is_array
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void test_is_array()
|
||||
{
|
||||
static_assert( std::is_array<T>::value, "");
|
||||
static_assert( std::is_array<const T>::value, "");
|
||||
static_assert( std::is_array<volatile T>::value, "");
|
||||
static_assert( std::is_array<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_array_v<T>, "");
|
||||
static_assert( std::is_array_v<const T>, "");
|
||||
static_assert( std::is_array_v<volatile T>, "");
|
||||
static_assert( std::is_array_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_is_not_array()
|
||||
{
|
||||
static_assert(!std::is_array<T>::value, "");
|
||||
static_assert(!std::is_array<const T>::value, "");
|
||||
static_assert(!std::is_array<volatile T>::value, "");
|
||||
static_assert(!std::is_array<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_array_v<T>, "");
|
||||
static_assert(!std::is_array_v<const T>, "");
|
||||
static_assert(!std::is_array_v<volatile T>, "");
|
||||
static_assert(!std::is_array_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Empty
|
||||
{
|
||||
};
|
||||
|
||||
class NotEmpty
|
||||
{
|
||||
virtual ~NotEmpty();
|
||||
};
|
||||
|
||||
union Union {};
|
||||
|
||||
struct bit_zero
|
||||
{
|
||||
int : 0;
|
||||
};
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual ~Abstract() = 0;
|
||||
};
|
||||
|
||||
enum Enum {zero, one};
|
||||
|
||||
typedef void (*FunctionPtr)();
|
||||
|
||||
int main()
|
||||
{
|
||||
test_is_array<char[3]>();
|
||||
test_is_array<char[]>();
|
||||
test_is_array<Union[]>();
|
||||
|
||||
test_is_not_array<std::nullptr_t>();
|
||||
test_is_not_array<void>();
|
||||
test_is_not_array<int&>();
|
||||
test_is_not_array<int&&>();
|
||||
test_is_not_array<int*>();
|
||||
test_is_not_array<double>();
|
||||
test_is_not_array<const int*>();
|
||||
test_is_not_array<Enum>();
|
||||
test_is_not_array<Union>();
|
||||
test_is_not_array<FunctionPtr>();
|
||||
test_is_not_array<Empty>();
|
||||
test_is_not_array<bit_zero>();
|
||||
test_is_not_array<NotEmpty>();
|
||||
test_is_not_array<Abstract>();
|
||||
}
|
@@ -0,0 +1,97 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// type_traits
|
||||
|
||||
// is_class
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void test_is_class()
|
||||
{
|
||||
static_assert( std::is_class<T>::value, "");
|
||||
static_assert( std::is_class<const T>::value, "");
|
||||
static_assert( std::is_class<volatile T>::value, "");
|
||||
static_assert( std::is_class<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_class_v<T>, "");
|
||||
static_assert( std::is_class_v<const T>, "");
|
||||
static_assert( std::is_class_v<volatile T>, "");
|
||||
static_assert( std::is_class_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_is_not_class()
|
||||
{
|
||||
static_assert(!std::is_class<T>::value, "");
|
||||
static_assert(!std::is_class<const T>::value, "");
|
||||
static_assert(!std::is_class<volatile T>::value, "");
|
||||
static_assert(!std::is_class<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_class_v<T>, "");
|
||||
static_assert(!std::is_class_v<const T>, "");
|
||||
static_assert(!std::is_class_v<volatile T>, "");
|
||||
static_assert(!std::is_class_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Empty
|
||||
{
|
||||
};
|
||||
|
||||
class NotEmpty
|
||||
{
|
||||
virtual ~NotEmpty();
|
||||
};
|
||||
|
||||
union Union {};
|
||||
|
||||
struct bit_zero
|
||||
{
|
||||
int : 0;
|
||||
};
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual ~Abstract() = 0;
|
||||
};
|
||||
|
||||
enum Enum {zero, one};
|
||||
|
||||
typedef void (*FunctionPtr)();
|
||||
|
||||
int main()
|
||||
{
|
||||
test_is_class<Empty>();
|
||||
test_is_class<bit_zero>();
|
||||
test_is_class<NotEmpty>();
|
||||
test_is_class<Abstract>();
|
||||
|
||||
#if TEST_STD_VER >= 11
|
||||
// In C++03 we have an emulation of std::nullptr_t
|
||||
test_is_not_class<std::nullptr_t>();
|
||||
#endif
|
||||
test_is_not_class<void>();
|
||||
test_is_not_class<int>();
|
||||
test_is_not_class<int&>();
|
||||
#if TEST_STD_VER >= 11
|
||||
test_is_not_class<int&&>();
|
||||
#endif
|
||||
test_is_not_class<int*>();
|
||||
test_is_not_class<double>();
|
||||
test_is_not_class<const int*>();
|
||||
test_is_not_class<char[3]>();
|
||||
test_is_not_class<char[]>();
|
||||
test_is_not_class<Enum>();
|
||||
test_is_not_class<Union>();
|
||||
test_is_not_class<FunctionPtr>();
|
||||
}
|
@@ -0,0 +1,92 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// type_traits
|
||||
|
||||
// is_enum
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void test_is_enum()
|
||||
{
|
||||
static_assert( std::is_enum<T>::value, "");
|
||||
static_assert( std::is_enum<const T>::value, "");
|
||||
static_assert( std::is_enum<volatile T>::value, "");
|
||||
static_assert( std::is_enum<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_enum_v<T>, "");
|
||||
static_assert( std::is_enum_v<const T>, "");
|
||||
static_assert( std::is_enum_v<volatile T>, "");
|
||||
static_assert( std::is_enum_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_is_not_enum()
|
||||
{
|
||||
static_assert(!std::is_enum<T>::value, "");
|
||||
static_assert(!std::is_enum<const T>::value, "");
|
||||
static_assert(!std::is_enum<volatile T>::value, "");
|
||||
static_assert(!std::is_enum<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_enum_v<T>, "");
|
||||
static_assert(!std::is_enum_v<const T>, "");
|
||||
static_assert(!std::is_enum_v<volatile T>, "");
|
||||
static_assert(!std::is_enum_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Empty
|
||||
{
|
||||
};
|
||||
|
||||
class NotEmpty
|
||||
{
|
||||
virtual ~NotEmpty();
|
||||
};
|
||||
|
||||
union Union {};
|
||||
|
||||
struct bit_zero
|
||||
{
|
||||
int : 0;
|
||||
};
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual ~Abstract() = 0;
|
||||
};
|
||||
|
||||
enum Enum {zero, one};
|
||||
|
||||
typedef void (*FunctionPtr)();
|
||||
|
||||
int main()
|
||||
{
|
||||
test_is_enum<Enum>();
|
||||
|
||||
test_is_not_enum<std::nullptr_t>();
|
||||
test_is_not_enum<void>();
|
||||
test_is_not_enum<int>();
|
||||
test_is_not_enum<int&>();
|
||||
test_is_not_enum<int&&>();
|
||||
test_is_not_enum<int*>();
|
||||
test_is_not_enum<double>();
|
||||
test_is_not_enum<const int*>();
|
||||
test_is_not_enum<char[3]>();
|
||||
test_is_not_enum<char[]>();
|
||||
test_is_not_enum<Union>();
|
||||
test_is_not_enum<Empty>();
|
||||
test_is_not_enum<bit_zero>();
|
||||
test_is_not_enum<NotEmpty>();
|
||||
test_is_not_enum<Abstract>();
|
||||
test_is_not_enum<FunctionPtr>();
|
||||
}
|
@@ -0,0 +1,100 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// type_traits
|
||||
|
||||
// is_floating_point
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void test_is_floating_point()
|
||||
{
|
||||
static_assert( std::is_floating_point<T>::value, "");
|
||||
static_assert( std::is_floating_point<const T>::value, "");
|
||||
static_assert( std::is_floating_point<volatile T>::value, "");
|
||||
static_assert( std::is_floating_point<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_floating_point_v<T>, "");
|
||||
static_assert( std::is_floating_point_v<const T>, "");
|
||||
static_assert( std::is_floating_point_v<volatile T>, "");
|
||||
static_assert( std::is_floating_point_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_is_not_floating_point()
|
||||
{
|
||||
static_assert(!std::is_floating_point<T>::value, "");
|
||||
static_assert(!std::is_floating_point<const T>::value, "");
|
||||
static_assert(!std::is_floating_point<volatile T>::value, "");
|
||||
static_assert(!std::is_floating_point<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_floating_point_v<T>, "");
|
||||
static_assert(!std::is_floating_point_v<const T>, "");
|
||||
static_assert(!std::is_floating_point_v<volatile T>, "");
|
||||
static_assert(!std::is_floating_point_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Empty
|
||||
{
|
||||
};
|
||||
|
||||
class NotEmpty
|
||||
{
|
||||
virtual ~NotEmpty();
|
||||
};
|
||||
|
||||
union Union {};
|
||||
|
||||
struct bit_zero
|
||||
{
|
||||
int : 0;
|
||||
};
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual ~Abstract() = 0;
|
||||
};
|
||||
|
||||
enum Enum {zero, one};
|
||||
|
||||
typedef void (*FunctionPtr)();
|
||||
|
||||
int main()
|
||||
{
|
||||
test_is_floating_point<float>();
|
||||
test_is_floating_point<double>();
|
||||
test_is_floating_point<long double>();
|
||||
|
||||
test_is_not_floating_point<short>();
|
||||
test_is_not_floating_point<unsigned short>();
|
||||
test_is_not_floating_point<int>();
|
||||
test_is_not_floating_point<unsigned int>();
|
||||
test_is_not_floating_point<long>();
|
||||
test_is_not_floating_point<unsigned long>();
|
||||
|
||||
test_is_not_floating_point<std::nullptr_t>();
|
||||
test_is_not_floating_point<void>();
|
||||
test_is_not_floating_point<int&>();
|
||||
test_is_not_floating_point<int&&>();
|
||||
test_is_not_floating_point<int*>();
|
||||
test_is_not_floating_point<const int*>();
|
||||
test_is_not_floating_point<char[3]>();
|
||||
test_is_not_floating_point<char[]>();
|
||||
test_is_not_floating_point<Union>();
|
||||
test_is_not_floating_point<Empty>();
|
||||
test_is_not_floating_point<bit_zero>();
|
||||
test_is_not_floating_point<NotEmpty>();
|
||||
test_is_not_floating_point<Abstract>();
|
||||
test_is_not_floating_point<Enum>();
|
||||
test_is_not_floating_point<FunctionPtr>();
|
||||
}
|
@@ -0,0 +1,97 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// type_traits
|
||||
|
||||
// is_function
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void test_is_function()
|
||||
{
|
||||
static_assert( std::is_function<T>::value, "");
|
||||
static_assert( std::is_function<const T>::value, "");
|
||||
static_assert( std::is_function<volatile T>::value, "");
|
||||
static_assert( std::is_function<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_function_v<T>, "");
|
||||
static_assert( std::is_function_v<const T>, "");
|
||||
static_assert( std::is_function_v<volatile T>, "");
|
||||
static_assert( std::is_function_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_is_not_function()
|
||||
{
|
||||
static_assert(!std::is_function<T>::value, "");
|
||||
static_assert(!std::is_function<const T>::value, "");
|
||||
static_assert(!std::is_function<volatile T>::value, "");
|
||||
static_assert(!std::is_function<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_function_v<T>, "");
|
||||
static_assert(!std::is_function_v<const T>, "");
|
||||
static_assert(!std::is_function_v<volatile T>, "");
|
||||
static_assert(!std::is_function_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Empty
|
||||
{
|
||||
};
|
||||
|
||||
class NotEmpty
|
||||
{
|
||||
virtual ~NotEmpty();
|
||||
};
|
||||
|
||||
union Union {};
|
||||
|
||||
struct bit_zero
|
||||
{
|
||||
int : 0;
|
||||
};
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual ~Abstract() = 0;
|
||||
};
|
||||
|
||||
enum Enum {zero, one};
|
||||
|
||||
typedef void (*FunctionPtr)();
|
||||
|
||||
int main()
|
||||
{
|
||||
test_is_function<void(void)>();
|
||||
test_is_function<int(int)>();
|
||||
test_is_function<int(int, double)>();
|
||||
test_is_function<int(Abstract *)>();
|
||||
test_is_function<void(...)>();
|
||||
|
||||
test_is_not_function<std::nullptr_t>();
|
||||
test_is_not_function<void>();
|
||||
test_is_not_function<int>();
|
||||
test_is_not_function<int&>();
|
||||
test_is_not_function<int&&>();
|
||||
test_is_not_function<int*>();
|
||||
test_is_not_function<double>();
|
||||
test_is_not_function<char[3]>();
|
||||
test_is_not_function<char[]>();
|
||||
test_is_not_function<Union>();
|
||||
test_is_not_function<Enum>();
|
||||
test_is_not_function<FunctionPtr>(); // function pointer is not a function
|
||||
test_is_not_function<Empty>();
|
||||
test_is_not_function<bit_zero>();
|
||||
test_is_not_function<NotEmpty>();
|
||||
test_is_not_function<Abstract>();
|
||||
test_is_not_function<Abstract*>();
|
||||
}
|
@@ -0,0 +1,103 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// type_traits
|
||||
|
||||
// is_integral
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void test_is_integral()
|
||||
{
|
||||
static_assert( std::is_integral<T>::value, "");
|
||||
static_assert( std::is_integral<const T>::value, "");
|
||||
static_assert( std::is_integral<volatile T>::value, "");
|
||||
static_assert( std::is_integral<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_integral_v<T>, "");
|
||||
static_assert( std::is_integral_v<const T>, "");
|
||||
static_assert( std::is_integral_v<volatile T>, "");
|
||||
static_assert( std::is_integral_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_is_not_integral()
|
||||
{
|
||||
static_assert(!std::is_integral<T>::value, "");
|
||||
static_assert(!std::is_integral<const T>::value, "");
|
||||
static_assert(!std::is_integral<volatile T>::value, "");
|
||||
static_assert(!std::is_integral<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_integral_v<T>, "");
|
||||
static_assert(!std::is_integral_v<const T>, "");
|
||||
static_assert(!std::is_integral_v<volatile T>, "");
|
||||
static_assert(!std::is_integral_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Empty
|
||||
{
|
||||
};
|
||||
|
||||
class NotEmpty
|
||||
{
|
||||
virtual ~NotEmpty();
|
||||
};
|
||||
|
||||
union Union {};
|
||||
|
||||
struct bit_zero
|
||||
{
|
||||
int : 0;
|
||||
};
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual ~Abstract() = 0;
|
||||
};
|
||||
|
||||
enum Enum {zero, one};
|
||||
|
||||
typedef void (*FunctionPtr)();
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
test_is_integral<short>();
|
||||
test_is_integral<unsigned short>();
|
||||
test_is_integral<int>();
|
||||
test_is_integral<unsigned int>();
|
||||
test_is_integral<long>();
|
||||
test_is_integral<unsigned long>();
|
||||
test_is_integral<bool>();
|
||||
test_is_integral<char>();
|
||||
test_is_integral<signed char>();
|
||||
test_is_integral<unsigned char>();
|
||||
test_is_integral<wchar_t>();
|
||||
|
||||
test_is_not_integral<std::nullptr_t>();
|
||||
test_is_not_integral<void>();
|
||||
test_is_not_integral<int&>();
|
||||
test_is_not_integral<int&&>();
|
||||
test_is_not_integral<int*>();
|
||||
test_is_not_integral<double>();
|
||||
test_is_not_integral<const int*>();
|
||||
test_is_not_integral<char[3]>();
|
||||
test_is_not_integral<char[]>();
|
||||
test_is_not_integral<Union>();
|
||||
test_is_not_integral<Enum>();
|
||||
test_is_not_integral<FunctionPtr>();
|
||||
test_is_not_integral<Empty>();
|
||||
test_is_not_integral<bit_zero>();
|
||||
test_is_not_integral<NotEmpty>();
|
||||
test_is_not_integral<Abstract>();
|
||||
}
|
@@ -0,0 +1,94 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// type_traits
|
||||
|
||||
// is_lvalue_reference
|
||||
|
||||
// UNSUPPORTED: c++98, c++03
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void test_is_lvalue_reference()
|
||||
{
|
||||
static_assert( std::is_lvalue_reference<T>::value, "");
|
||||
static_assert( std::is_lvalue_reference<const T>::value, "");
|
||||
static_assert( std::is_lvalue_reference<volatile T>::value, "");
|
||||
static_assert( std::is_lvalue_reference<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_lvalue_reference_v<T>, "");
|
||||
static_assert( std::is_lvalue_reference_v<const T>, "");
|
||||
static_assert( std::is_lvalue_reference_v<volatile T>, "");
|
||||
static_assert( std::is_lvalue_reference_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_is_not_lvalue_reference()
|
||||
{
|
||||
static_assert(!std::is_lvalue_reference<T>::value, "");
|
||||
static_assert(!std::is_lvalue_reference<const T>::value, "");
|
||||
static_assert(!std::is_lvalue_reference<volatile T>::value, "");
|
||||
static_assert(!std::is_lvalue_reference<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_lvalue_reference_v<T>, "");
|
||||
static_assert(!std::is_lvalue_reference_v<const T>, "");
|
||||
static_assert(!std::is_lvalue_reference_v<volatile T>, "");
|
||||
static_assert(!std::is_lvalue_reference_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Empty
|
||||
{
|
||||
};
|
||||
|
||||
class NotEmpty
|
||||
{
|
||||
virtual ~NotEmpty();
|
||||
};
|
||||
|
||||
union Union {};
|
||||
|
||||
struct bit_zero
|
||||
{
|
||||
int : 0;
|
||||
};
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual ~Abstract() = 0;
|
||||
};
|
||||
|
||||
enum Enum {zero, one};
|
||||
|
||||
typedef void (*FunctionPtr)();
|
||||
|
||||
int main()
|
||||
{
|
||||
test_is_lvalue_reference<int&>();
|
||||
|
||||
test_is_not_lvalue_reference<std::nullptr_t>();
|
||||
test_is_not_lvalue_reference<void>();
|
||||
test_is_not_lvalue_reference<int>();
|
||||
test_is_not_lvalue_reference<int*>();
|
||||
test_is_not_lvalue_reference<int&&>();
|
||||
test_is_not_lvalue_reference<double>();
|
||||
test_is_not_lvalue_reference<const int*>();
|
||||
test_is_not_lvalue_reference<char[3]>();
|
||||
test_is_not_lvalue_reference<char[]>();
|
||||
test_is_not_lvalue_reference<Union>();
|
||||
test_is_not_lvalue_reference<Enum>();
|
||||
test_is_not_lvalue_reference<FunctionPtr>();
|
||||
test_is_not_lvalue_reference<Empty>();
|
||||
test_is_not_lvalue_reference<bit_zero>();
|
||||
test_is_not_lvalue_reference<NotEmpty>();
|
||||
test_is_not_lvalue_reference<Abstract>();
|
||||
}
|
@@ -0,0 +1,96 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// type_traits
|
||||
|
||||
// is_member_object_pointer
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void test_is_member_object_pointer()
|
||||
{
|
||||
static_assert( std::is_member_object_pointer<T>::value, "");
|
||||
static_assert( std::is_member_object_pointer<const T>::value, "");
|
||||
static_assert( std::is_member_object_pointer<volatile T>::value, "");
|
||||
static_assert( std::is_member_object_pointer<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_member_object_pointer_v<T>, "");
|
||||
static_assert( std::is_member_object_pointer_v<const T>, "");
|
||||
static_assert( std::is_member_object_pointer_v<volatile T>, "");
|
||||
static_assert( std::is_member_object_pointer_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_is_not_member_object_pointer()
|
||||
{
|
||||
static_assert(!std::is_member_object_pointer<T>::value, "");
|
||||
static_assert(!std::is_member_object_pointer<const T>::value, "");
|
||||
static_assert(!std::is_member_object_pointer<volatile T>::value, "");
|
||||
static_assert(!std::is_member_object_pointer<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_member_object_pointer_v<T>, "");
|
||||
static_assert(!std::is_member_object_pointer_v<const T>, "");
|
||||
static_assert(!std::is_member_object_pointer_v<volatile T>, "");
|
||||
static_assert(!std::is_member_object_pointer_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Empty
|
||||
{
|
||||
};
|
||||
|
||||
class NotEmpty
|
||||
{
|
||||
virtual ~NotEmpty();
|
||||
};
|
||||
|
||||
union Union {};
|
||||
|
||||
struct bit_zero
|
||||
{
|
||||
int : 0;
|
||||
};
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual ~Abstract() = 0;
|
||||
};
|
||||
|
||||
enum Enum {zero, one};
|
||||
|
||||
typedef void (*FunctionPtr)();
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
test_is_member_object_pointer<int Abstract::*>();
|
||||
test_is_member_object_pointer<double NotEmpty::*>();
|
||||
test_is_member_object_pointer<FunctionPtr Empty::*>();
|
||||
|
||||
test_is_not_member_object_pointer<std::nullptr_t>();
|
||||
test_is_not_member_object_pointer<void>();
|
||||
test_is_not_member_object_pointer<int>();
|
||||
test_is_not_member_object_pointer<int&>();
|
||||
test_is_not_member_object_pointer<int&&>();
|
||||
test_is_not_member_object_pointer<int*>();
|
||||
test_is_not_member_object_pointer<double>();
|
||||
test_is_not_member_object_pointer<const int*>();
|
||||
test_is_not_member_object_pointer<char[3]>();
|
||||
test_is_not_member_object_pointer<char[]>();
|
||||
test_is_not_member_object_pointer<Union>();
|
||||
test_is_not_member_object_pointer<Enum>();
|
||||
test_is_not_member_object_pointer<FunctionPtr>();
|
||||
test_is_not_member_object_pointer<Empty>();
|
||||
test_is_not_member_object_pointer<bit_zero>();
|
||||
test_is_not_member_object_pointer<NotEmpty>();
|
||||
test_is_not_member_object_pointer<Abstract>();
|
||||
}
|
@@ -0,0 +1,97 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// type_traits
|
||||
|
||||
// is_member_pointer
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void test_is_member_pointer()
|
||||
{
|
||||
static_assert( std::is_member_pointer<T>::value, "");
|
||||
static_assert( std::is_member_pointer<const T>::value, "");
|
||||
static_assert( std::is_member_pointer<volatile T>::value, "");
|
||||
static_assert( std::is_member_pointer<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_member_pointer_v<T>, "");
|
||||
static_assert( std::is_member_pointer_v<const T>, "");
|
||||
static_assert( std::is_member_pointer_v<volatile T>, "");
|
||||
static_assert( std::is_member_pointer_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_is_not_member_pointer()
|
||||
{
|
||||
static_assert(!std::is_member_pointer<T>::value, "");
|
||||
static_assert(!std::is_member_pointer<const T>::value, "");
|
||||
static_assert(!std::is_member_pointer<volatile T>::value, "");
|
||||
static_assert(!std::is_member_pointer<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_member_pointer_v<T>, "");
|
||||
static_assert(!std::is_member_pointer_v<const T>, "");
|
||||
static_assert(!std::is_member_pointer_v<volatile T>, "");
|
||||
static_assert(!std::is_member_pointer_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Empty
|
||||
{
|
||||
};
|
||||
|
||||
class NotEmpty
|
||||
{
|
||||
virtual ~NotEmpty();
|
||||
};
|
||||
|
||||
union Union {};
|
||||
|
||||
struct bit_zero
|
||||
{
|
||||
int : 0;
|
||||
};
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual ~Abstract() = 0;
|
||||
};
|
||||
|
||||
enum Enum {zero, one};
|
||||
|
||||
typedef void (*FunctionPtr)();
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
test_is_member_pointer<int Abstract::*>();
|
||||
test_is_member_pointer<double NotEmpty::*>();
|
||||
test_is_member_pointer<FunctionPtr Empty::*>();
|
||||
test_is_member_pointer<void (Empty::*)()>();
|
||||
|
||||
test_is_not_member_pointer<std::nullptr_t>();
|
||||
test_is_not_member_pointer<void>();
|
||||
test_is_not_member_pointer<int>();
|
||||
test_is_not_member_pointer<int&>();
|
||||
test_is_not_member_pointer<int&&>();
|
||||
test_is_not_member_pointer<int*>();
|
||||
test_is_not_member_pointer<double>();
|
||||
test_is_not_member_pointer<const int*>();
|
||||
test_is_not_member_pointer<char[3]>();
|
||||
test_is_not_member_pointer<char[]>();
|
||||
test_is_not_member_pointer<Union>();
|
||||
test_is_not_member_pointer<Enum>();
|
||||
test_is_not_member_pointer<FunctionPtr>();
|
||||
test_is_not_member_pointer<Empty>();
|
||||
test_is_not_member_pointer<bit_zero>();
|
||||
test_is_not_member_pointer<NotEmpty>();
|
||||
test_is_not_member_pointer<Abstract>();
|
||||
}
|
@@ -0,0 +1,94 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// type_traits
|
||||
|
||||
// is_null_pointer
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void test_is_null_pointer()
|
||||
{
|
||||
static_assert( std::is_null_pointer<T>::value, "");
|
||||
static_assert( std::is_null_pointer<const T>::value, "");
|
||||
static_assert( std::is_null_pointer<volatile T>::value, "");
|
||||
static_assert( std::is_null_pointer<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_null_pointer_v<T>, "");
|
||||
static_assert( std::is_null_pointer_v<const T>, "");
|
||||
static_assert( std::is_null_pointer_v<volatile T>, "");
|
||||
static_assert( std::is_null_pointer_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_is_not_null_pointer()
|
||||
{
|
||||
static_assert(!std::is_null_pointer<T>::value, "");
|
||||
static_assert(!std::is_null_pointer<const T>::value, "");
|
||||
static_assert(!std::is_null_pointer<volatile T>::value, "");
|
||||
static_assert(!std::is_null_pointer<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_null_pointer_v<T>, "");
|
||||
static_assert(!std::is_null_pointer_v<const T>, "");
|
||||
static_assert(!std::is_null_pointer_v<volatile T>, "");
|
||||
static_assert(!std::is_null_pointer_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Empty
|
||||
{
|
||||
};
|
||||
|
||||
class NotEmpty
|
||||
{
|
||||
virtual ~NotEmpty();
|
||||
};
|
||||
|
||||
union Union {};
|
||||
|
||||
struct bit_zero
|
||||
{
|
||||
int : 0;
|
||||
};
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual ~Abstract() = 0;
|
||||
};
|
||||
|
||||
enum Enum {zero, one};
|
||||
|
||||
typedef void (*FunctionPtr)();
|
||||
|
||||
int main()
|
||||
{
|
||||
test_is_null_pointer<std::nullptr_t>();
|
||||
|
||||
test_is_not_null_pointer<void>();
|
||||
test_is_not_null_pointer<int>();
|
||||
test_is_not_null_pointer<int&>();
|
||||
test_is_not_null_pointer<int&&>();
|
||||
test_is_not_null_pointer<int*>();
|
||||
test_is_not_null_pointer<double>();
|
||||
test_is_not_null_pointer<const int*>();
|
||||
test_is_not_null_pointer<char[3]>();
|
||||
test_is_not_null_pointer<char[]>();
|
||||
test_is_not_null_pointer<Union>();
|
||||
test_is_not_null_pointer<Enum>();
|
||||
test_is_not_null_pointer<FunctionPtr>();
|
||||
test_is_not_null_pointer<Empty>();
|
||||
test_is_not_null_pointer<bit_zero>();
|
||||
test_is_not_null_pointer<NotEmpty>();
|
||||
test_is_not_null_pointer<Abstract>();
|
||||
}
|
@@ -0,0 +1,93 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// type_traits
|
||||
|
||||
// is_pointer
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void test_is_pointer()
|
||||
{
|
||||
static_assert( std::is_pointer<T>::value, "");
|
||||
static_assert( std::is_pointer<const T>::value, "");
|
||||
static_assert( std::is_pointer<volatile T>::value, "");
|
||||
static_assert( std::is_pointer<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_pointer_v<T>, "");
|
||||
static_assert( std::is_pointer_v<const T>, "");
|
||||
static_assert( std::is_pointer_v<volatile T>, "");
|
||||
static_assert( std::is_pointer_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_is_not_pointer()
|
||||
{
|
||||
static_assert(!std::is_pointer<T>::value, "");
|
||||
static_assert(!std::is_pointer<const T>::value, "");
|
||||
static_assert(!std::is_pointer<volatile T>::value, "");
|
||||
static_assert(!std::is_pointer<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_pointer_v<T>, "");
|
||||
static_assert(!std::is_pointer_v<const T>, "");
|
||||
static_assert(!std::is_pointer_v<volatile T>, "");
|
||||
static_assert(!std::is_pointer_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Empty
|
||||
{
|
||||
};
|
||||
|
||||
class NotEmpty
|
||||
{
|
||||
virtual ~NotEmpty();
|
||||
};
|
||||
|
||||
union Union {};
|
||||
|
||||
struct bit_zero
|
||||
{
|
||||
int : 0;
|
||||
};
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual ~Abstract() = 0;
|
||||
};
|
||||
|
||||
enum Enum {zero, one};
|
||||
|
||||
typedef void (*FunctionPtr)();
|
||||
|
||||
int main()
|
||||
{
|
||||
test_is_pointer<void*>();
|
||||
test_is_pointer<int*>();
|
||||
test_is_pointer<const int*>();
|
||||
test_is_pointer<Abstract*>();
|
||||
test_is_pointer<FunctionPtr>();
|
||||
|
||||
test_is_not_pointer<std::nullptr_t>();
|
||||
test_is_not_pointer<void>();
|
||||
test_is_not_pointer<int&>();
|
||||
test_is_not_pointer<int&&>();
|
||||
test_is_not_pointer<double>();
|
||||
test_is_not_pointer<char[3]>();
|
||||
test_is_not_pointer<char[]>();
|
||||
test_is_not_pointer<Union>();
|
||||
test_is_not_pointer<Enum>();
|
||||
test_is_not_pointer<Empty>();
|
||||
test_is_not_pointer<bit_zero>();
|
||||
test_is_not_pointer<NotEmpty>();
|
||||
test_is_not_pointer<Abstract>();
|
||||
}
|
@@ -0,0 +1,94 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// type_traits
|
||||
|
||||
// is_rvalue_reference
|
||||
|
||||
// UNSUPPORTED: c++98, c++03
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void test_is_rvalue_reference()
|
||||
{
|
||||
static_assert( std::is_rvalue_reference<T>::value, "");
|
||||
static_assert( std::is_rvalue_reference<const T>::value, "");
|
||||
static_assert( std::is_rvalue_reference<volatile T>::value, "");
|
||||
static_assert( std::is_rvalue_reference<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_rvalue_reference_v<T>, "");
|
||||
static_assert( std::is_rvalue_reference_v<const T>, "");
|
||||
static_assert( std::is_rvalue_reference_v<volatile T>, "");
|
||||
static_assert( std::is_rvalue_reference_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_is_not_rvalue_reference()
|
||||
{
|
||||
static_assert(!std::is_rvalue_reference<T>::value, "");
|
||||
static_assert(!std::is_rvalue_reference<const T>::value, "");
|
||||
static_assert(!std::is_rvalue_reference<volatile T>::value, "");
|
||||
static_assert(!std::is_rvalue_reference<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_rvalue_reference_v<T>, "");
|
||||
static_assert(!std::is_rvalue_reference_v<const T>, "");
|
||||
static_assert(!std::is_rvalue_reference_v<volatile T>, "");
|
||||
static_assert(!std::is_rvalue_reference_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Empty
|
||||
{
|
||||
};
|
||||
|
||||
class NotEmpty
|
||||
{
|
||||
virtual ~NotEmpty();
|
||||
};
|
||||
|
||||
union Union {};
|
||||
|
||||
struct bit_zero
|
||||
{
|
||||
int : 0;
|
||||
};
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual ~Abstract() = 0;
|
||||
};
|
||||
|
||||
enum Enum {zero, one};
|
||||
|
||||
typedef void (*FunctionPtr)();
|
||||
|
||||
int main()
|
||||
{
|
||||
test_is_rvalue_reference<int&&>();
|
||||
|
||||
test_is_not_rvalue_reference<std::nullptr_t>();
|
||||
test_is_not_rvalue_reference<void>();
|
||||
test_is_not_rvalue_reference<int>();
|
||||
test_is_not_rvalue_reference<int*>();
|
||||
test_is_not_rvalue_reference<int&>();
|
||||
test_is_not_rvalue_reference<double>();
|
||||
test_is_not_rvalue_reference<const int*>();
|
||||
test_is_not_rvalue_reference<char[3]>();
|
||||
test_is_not_rvalue_reference<char[]>();
|
||||
test_is_not_rvalue_reference<Union>();
|
||||
test_is_not_rvalue_reference<Enum>();
|
||||
test_is_not_rvalue_reference<FunctionPtr>();
|
||||
test_is_not_rvalue_reference<Empty>();
|
||||
test_is_not_rvalue_reference<bit_zero>();
|
||||
test_is_not_rvalue_reference<NotEmpty>();
|
||||
test_is_not_rvalue_reference<Abstract>();
|
||||
}
|
@@ -0,0 +1,92 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// type_traits
|
||||
|
||||
// is_union
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void test_is_union()
|
||||
{
|
||||
static_assert( std::is_union<T>::value, "");
|
||||
static_assert( std::is_union<const T>::value, "");
|
||||
static_assert( std::is_union<volatile T>::value, "");
|
||||
static_assert( std::is_union<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_union_v<T>, "");
|
||||
static_assert( std::is_union_v<const T>, "");
|
||||
static_assert( std::is_union_v<volatile T>, "");
|
||||
static_assert( std::is_union_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_is_not_union()
|
||||
{
|
||||
static_assert(!std::is_union<T>::value, "");
|
||||
static_assert(!std::is_union<const T>::value, "");
|
||||
static_assert(!std::is_union<volatile T>::value, "");
|
||||
static_assert(!std::is_union<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_union_v<T>, "");
|
||||
static_assert(!std::is_union_v<const T>, "");
|
||||
static_assert(!std::is_union_v<volatile T>, "");
|
||||
static_assert(!std::is_union_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Empty
|
||||
{
|
||||
};
|
||||
|
||||
class NotEmpty
|
||||
{
|
||||
virtual ~NotEmpty();
|
||||
};
|
||||
|
||||
union Union {};
|
||||
|
||||
struct bit_zero
|
||||
{
|
||||
int : 0;
|
||||
};
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual ~Abstract() = 0;
|
||||
};
|
||||
|
||||
enum Enum {zero, one};
|
||||
|
||||
typedef void (*FunctionPtr)();
|
||||
|
||||
int main()
|
||||
{
|
||||
test_is_union<Union>();
|
||||
|
||||
test_is_not_union<std::nullptr_t>();
|
||||
test_is_not_union<void>();
|
||||
test_is_not_union<int>();
|
||||
test_is_not_union<int&>();
|
||||
test_is_not_union<int&&>();
|
||||
test_is_not_union<int*>();
|
||||
test_is_not_union<double>();
|
||||
test_is_not_union<const int*>();
|
||||
test_is_not_union<char[3]>();
|
||||
test_is_not_union<char[]>();
|
||||
test_is_not_union<Enum>();
|
||||
test_is_not_union<FunctionPtr>();
|
||||
test_is_not_union<Empty>();
|
||||
test_is_not_union<bit_zero>();
|
||||
test_is_not_union<NotEmpty>();
|
||||
test_is_not_union<Abstract>();
|
||||
}
|
@@ -0,0 +1,91 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// type_traits
|
||||
|
||||
// is_void
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void test_is_void()
|
||||
{
|
||||
static_assert( std::is_void<T>::value, "");
|
||||
static_assert( std::is_void<const T>::value, "");
|
||||
static_assert( std::is_void<volatile T>::value, "");
|
||||
static_assert( std::is_void<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_void_v<T>, "");
|
||||
static_assert( std::is_void_v<const T>, "");
|
||||
static_assert( std::is_void_v<volatile T>, "");
|
||||
static_assert( std::is_void_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_is_not_void()
|
||||
{
|
||||
static_assert(!std::is_void<T>::value, "");
|
||||
static_assert(!std::is_void<const T>::value, "");
|
||||
static_assert(!std::is_void<volatile T>::value, "");
|
||||
static_assert(!std::is_void<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_void_v<T>, "");
|
||||
static_assert(!std::is_void_v<const T>, "");
|
||||
static_assert(!std::is_void_v<volatile T>, "");
|
||||
static_assert(!std::is_void_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Empty
|
||||
{
|
||||
};
|
||||
|
||||
class NotEmpty
|
||||
{
|
||||
virtual ~NotEmpty();
|
||||
};
|
||||
|
||||
union Union {};
|
||||
|
||||
struct bit_zero
|
||||
{
|
||||
int : 0;
|
||||
};
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual ~Abstract() = 0;
|
||||
};
|
||||
|
||||
enum Enum {zero, one};
|
||||
|
||||
typedef void (*FunctionPtr)();
|
||||
|
||||
int main()
|
||||
{
|
||||
test_is_void<void>();
|
||||
|
||||
test_is_not_void<int>();
|
||||
test_is_not_void<int*>();
|
||||
test_is_not_void<int&>();
|
||||
test_is_not_void<int&&>();
|
||||
test_is_not_void<double>();
|
||||
test_is_not_void<const int*>();
|
||||
test_is_not_void<char[3]>();
|
||||
test_is_not_void<char[]>();
|
||||
test_is_not_void<Union>();
|
||||
test_is_not_void<Empty>();
|
||||
test_is_not_void<bit_zero>();
|
||||
test_is_not_void<NotEmpty>();
|
||||
test_is_not_void<Abstract>();
|
||||
test_is_not_void<Enum>();
|
||||
test_is_not_void<FunctionPtr>();
|
||||
}
|
@@ -0,0 +1,103 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// type_traits
|
||||
|
||||
// is_arithmetic
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void test_is_arithmetic()
|
||||
{
|
||||
static_assert( std::is_arithmetic<T>::value, "");
|
||||
static_assert( std::is_arithmetic<const T>::value, "");
|
||||
static_assert( std::is_arithmetic<volatile T>::value, "");
|
||||
static_assert( std::is_arithmetic<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_arithmetic_v<T>, "");
|
||||
static_assert( std::is_arithmetic_v<const T>, "");
|
||||
static_assert( std::is_arithmetic_v<volatile T>, "");
|
||||
static_assert( std::is_arithmetic_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_is_not_arithmetic()
|
||||
{
|
||||
static_assert(!std::is_arithmetic<T>::value, "");
|
||||
static_assert(!std::is_arithmetic<const T>::value, "");
|
||||
static_assert(!std::is_arithmetic<volatile T>::value, "");
|
||||
static_assert(!std::is_arithmetic<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_arithmetic_v<T>, "");
|
||||
static_assert(!std::is_arithmetic_v<const T>, "");
|
||||
static_assert(!std::is_arithmetic_v<volatile T>, "");
|
||||
static_assert(!std::is_arithmetic_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Empty
|
||||
{
|
||||
};
|
||||
|
||||
class NotEmpty
|
||||
{
|
||||
virtual ~NotEmpty();
|
||||
};
|
||||
|
||||
union Union {};
|
||||
|
||||
struct bit_zero
|
||||
{
|
||||
int : 0;
|
||||
};
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual ~Abstract() = 0;
|
||||
};
|
||||
|
||||
enum Enum {zero, one};
|
||||
|
||||
typedef void (*FunctionPtr)();
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
test_is_arithmetic<short>();
|
||||
test_is_arithmetic<unsigned short>();
|
||||
test_is_arithmetic<int>();
|
||||
test_is_arithmetic<unsigned int>();
|
||||
test_is_arithmetic<long>();
|
||||
test_is_arithmetic<unsigned long>();
|
||||
test_is_arithmetic<bool>();
|
||||
test_is_arithmetic<char>();
|
||||
test_is_arithmetic<signed char>();
|
||||
test_is_arithmetic<unsigned char>();
|
||||
test_is_arithmetic<wchar_t>();
|
||||
test_is_arithmetic<double>();
|
||||
|
||||
test_is_not_arithmetic<std::nullptr_t>();
|
||||
test_is_not_arithmetic<void>();
|
||||
test_is_not_arithmetic<int&>();
|
||||
test_is_not_arithmetic<int&&>();
|
||||
test_is_not_arithmetic<int*>();
|
||||
test_is_not_arithmetic<const int*>();
|
||||
test_is_not_arithmetic<char[3]>();
|
||||
test_is_not_arithmetic<char[]>();
|
||||
test_is_not_arithmetic<Union>();
|
||||
test_is_not_arithmetic<Enum>();
|
||||
test_is_not_arithmetic<FunctionPtr>();
|
||||
test_is_not_arithmetic<Empty>();
|
||||
test_is_not_arithmetic<bit_zero>();
|
||||
test_is_not_arithmetic<NotEmpty>();
|
||||
test_is_not_arithmetic<Abstract>();
|
||||
}
|
@@ -0,0 +1,94 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// type_traits
|
||||
|
||||
// is_compound
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void test_is_compound()
|
||||
{
|
||||
static_assert( std::is_compound<T>::value, "");
|
||||
static_assert( std::is_compound<const T>::value, "");
|
||||
static_assert( std::is_compound<volatile T>::value, "");
|
||||
static_assert( std::is_compound<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_compound_v<T>, "");
|
||||
static_assert( std::is_compound_v<const T>, "");
|
||||
static_assert( std::is_compound_v<volatile T>, "");
|
||||
static_assert( std::is_compound_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_is_not_compound()
|
||||
{
|
||||
static_assert(!std::is_compound<T>::value, "");
|
||||
static_assert(!std::is_compound<const T>::value, "");
|
||||
static_assert(!std::is_compound<volatile T>::value, "");
|
||||
static_assert(!std::is_compound<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_compound_v<T>, "");
|
||||
static_assert(!std::is_compound_v<const T>, "");
|
||||
static_assert(!std::is_compound_v<volatile T>, "");
|
||||
static_assert(!std::is_compound_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Empty
|
||||
{
|
||||
};
|
||||
|
||||
class NotEmpty
|
||||
{
|
||||
virtual ~NotEmpty();
|
||||
};
|
||||
|
||||
union Union {};
|
||||
|
||||
struct bit_zero
|
||||
{
|
||||
int : 0;
|
||||
};
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual ~Abstract() = 0;
|
||||
};
|
||||
|
||||
enum Enum {zero, one};
|
||||
|
||||
typedef void (*FunctionPtr)();
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
test_is_compound<char[3]>();
|
||||
test_is_compound<char[]>();
|
||||
test_is_compound<void *>();
|
||||
test_is_compound<FunctionPtr>();
|
||||
test_is_compound<int&>();
|
||||
test_is_compound<int&&>();
|
||||
test_is_compound<Union>();
|
||||
test_is_compound<Empty>();
|
||||
test_is_compound<bit_zero>();
|
||||
test_is_compound<int*>();
|
||||
test_is_compound<const int*>();
|
||||
test_is_compound<Enum>();
|
||||
test_is_compound<NotEmpty>();
|
||||
test_is_compound<Abstract>();
|
||||
|
||||
test_is_not_compound<std::nullptr_t>();
|
||||
test_is_not_compound<void>();
|
||||
test_is_not_compound<int>();
|
||||
test_is_not_compound<double>();
|
||||
}
|
@@ -0,0 +1,111 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// type_traits
|
||||
|
||||
// is_fundamental
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void test_is_fundamental()
|
||||
{
|
||||
static_assert( std::is_fundamental<T>::value, "");
|
||||
static_assert( std::is_fundamental<const T>::value, "");
|
||||
static_assert( std::is_fundamental<volatile T>::value, "");
|
||||
static_assert( std::is_fundamental<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_fundamental_v<T>, "");
|
||||
static_assert( std::is_fundamental_v<const T>, "");
|
||||
static_assert( std::is_fundamental_v<volatile T>, "");
|
||||
static_assert( std::is_fundamental_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_is_not_fundamental()
|
||||
{
|
||||
static_assert(!std::is_fundamental<T>::value, "");
|
||||
static_assert(!std::is_fundamental<const T>::value, "");
|
||||
static_assert(!std::is_fundamental<volatile T>::value, "");
|
||||
static_assert(!std::is_fundamental<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_fundamental_v<T>, "");
|
||||
static_assert(!std::is_fundamental_v<const T>, "");
|
||||
static_assert(!std::is_fundamental_v<volatile T>, "");
|
||||
static_assert(!std::is_fundamental_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Empty
|
||||
{
|
||||
};
|
||||
|
||||
class NotEmpty
|
||||
{
|
||||
virtual ~NotEmpty();
|
||||
};
|
||||
|
||||
union Union {};
|
||||
|
||||
struct bit_zero
|
||||
{
|
||||
int : 0;
|
||||
};
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual ~Abstract() = 0;
|
||||
};
|
||||
|
||||
enum Enum {zero, one};
|
||||
|
||||
typedef void (*FunctionPtr)();
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
test_is_fundamental<std::nullptr_t>();
|
||||
test_is_fundamental<void>();
|
||||
test_is_fundamental<short>();
|
||||
test_is_fundamental<unsigned short>();
|
||||
test_is_fundamental<int>();
|
||||
test_is_fundamental<unsigned int>();
|
||||
test_is_fundamental<long>();
|
||||
test_is_fundamental<unsigned long>();
|
||||
test_is_fundamental<long long>();
|
||||
test_is_fundamental<unsigned long long>();
|
||||
test_is_fundamental<bool>();
|
||||
test_is_fundamental<char>();
|
||||
test_is_fundamental<signed char>();
|
||||
test_is_fundamental<unsigned char>();
|
||||
test_is_fundamental<wchar_t>();
|
||||
test_is_fundamental<double>();
|
||||
test_is_fundamental<float>();
|
||||
test_is_fundamental<double>();
|
||||
test_is_fundamental<long double>();
|
||||
test_is_fundamental<char16_t>();
|
||||
test_is_fundamental<char32_t>();
|
||||
|
||||
test_is_not_fundamental<char[3]>();
|
||||
test_is_not_fundamental<char[]>();
|
||||
test_is_not_fundamental<void *>();
|
||||
test_is_not_fundamental<FunctionPtr>();
|
||||
test_is_not_fundamental<int&>();
|
||||
test_is_not_fundamental<int&&>();
|
||||
test_is_not_fundamental<Union>();
|
||||
test_is_not_fundamental<Empty>();
|
||||
test_is_not_fundamental<bit_zero>();
|
||||
test_is_not_fundamental<int*>();
|
||||
test_is_not_fundamental<const int*>();
|
||||
test_is_not_fundamental<Enum>();
|
||||
test_is_not_fundamental<NotEmpty>();
|
||||
test_is_not_fundamental<Abstract>();
|
||||
}
|
@@ -0,0 +1,101 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// type_traits
|
||||
|
||||
// is_member_pointer
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void test_is_member_pointer()
|
||||
{
|
||||
static_assert( std::is_member_pointer<T>::value, "");
|
||||
static_assert( std::is_member_pointer<const T>::value, "");
|
||||
static_assert( std::is_member_pointer<volatile T>::value, "");
|
||||
static_assert( std::is_member_pointer<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_member_pointer_v<T>, "");
|
||||
static_assert( std::is_member_pointer_v<const T>, "");
|
||||
static_assert( std::is_member_pointer_v<volatile T>, "");
|
||||
static_assert( std::is_member_pointer_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_is_not_member_pointer()
|
||||
{
|
||||
static_assert(!std::is_member_pointer<T>::value, "");
|
||||
static_assert(!std::is_member_pointer<const T>::value, "");
|
||||
static_assert(!std::is_member_pointer<volatile T>::value, "");
|
||||
static_assert(!std::is_member_pointer<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_member_pointer_v<T>, "");
|
||||
static_assert(!std::is_member_pointer_v<const T>, "");
|
||||
static_assert(!std::is_member_pointer_v<volatile T>, "");
|
||||
static_assert(!std::is_member_pointer_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Empty
|
||||
{
|
||||
};
|
||||
|
||||
class NotEmpty
|
||||
{
|
||||
virtual ~NotEmpty();
|
||||
};
|
||||
|
||||
union Union {};
|
||||
|
||||
struct bit_zero
|
||||
{
|
||||
int : 0;
|
||||
};
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual ~Abstract() = 0;
|
||||
};
|
||||
|
||||
enum Enum {zero, one};
|
||||
|
||||
typedef void (*FunctionPtr)();
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
// Arithmetic types (3.9.1), enumeration types, pointer types, pointer to member types (3.9.2),
|
||||
// std::nullptr_t, and cv-qualified versions of these types (3.9.3)
|
||||
// are collectively called scalar types.
|
||||
|
||||
test_is_member_pointer<int Empty::*>();
|
||||
test_is_member_pointer<void (Empty::*)(int)>();
|
||||
|
||||
test_is_not_member_pointer<std::nullptr_t>();
|
||||
test_is_not_member_pointer<void>();
|
||||
test_is_not_member_pointer<void *>();
|
||||
test_is_not_member_pointer<int>();
|
||||
test_is_not_member_pointer<int*>();
|
||||
test_is_not_member_pointer<const int*>();
|
||||
test_is_not_member_pointer<int&>();
|
||||
test_is_not_member_pointer<int&&>();
|
||||
test_is_not_member_pointer<double>();
|
||||
test_is_not_member_pointer<char[3]>();
|
||||
test_is_not_member_pointer<char[]>();
|
||||
test_is_not_member_pointer<Union>();
|
||||
test_is_not_member_pointer<Empty>();
|
||||
test_is_not_member_pointer<bit_zero>();
|
||||
test_is_not_member_pointer<NotEmpty>();
|
||||
test_is_not_member_pointer<Abstract>();
|
||||
test_is_not_member_pointer<int(int)>();
|
||||
test_is_not_member_pointer<Enum>();
|
||||
test_is_not_member_pointer<FunctionPtr>();
|
||||
}
|
@@ -0,0 +1,100 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// type_traits
|
||||
|
||||
// is_object
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void test_is_object()
|
||||
{
|
||||
static_assert( std::is_object<T>::value, "");
|
||||
static_assert( std::is_object<const T>::value, "");
|
||||
static_assert( std::is_object<volatile T>::value, "");
|
||||
static_assert( std::is_object<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_object_v<T>, "");
|
||||
static_assert( std::is_object_v<const T>, "");
|
||||
static_assert( std::is_object_v<volatile T>, "");
|
||||
static_assert( std::is_object_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_is_not_object()
|
||||
{
|
||||
static_assert(!std::is_object<T>::value, "");
|
||||
static_assert(!std::is_object<const T>::value, "");
|
||||
static_assert(!std::is_object<volatile T>::value, "");
|
||||
static_assert(!std::is_object<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_object_v<T>, "");
|
||||
static_assert(!std::is_object_v<const T>, "");
|
||||
static_assert(!std::is_object_v<volatile T>, "");
|
||||
static_assert(!std::is_object_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Empty
|
||||
{
|
||||
};
|
||||
|
||||
class NotEmpty
|
||||
{
|
||||
virtual ~NotEmpty();
|
||||
};
|
||||
|
||||
union Union {};
|
||||
|
||||
struct bit_zero
|
||||
{
|
||||
int : 0;
|
||||
};
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual ~Abstract() = 0;
|
||||
};
|
||||
|
||||
enum Enum {zero, one};
|
||||
|
||||
typedef void (*FunctionPtr)();
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
// An object type is a (possibly cv-qualified) type that is not a function type,
|
||||
// not a reference type, and not a void type.
|
||||
|
||||
test_is_object<std::nullptr_t>();
|
||||
test_is_object<void *>();
|
||||
test_is_object<char[3]>();
|
||||
test_is_object<char[]>();
|
||||
test_is_object<int>();
|
||||
test_is_object<int*>();
|
||||
test_is_object<Union>();
|
||||
test_is_object<int*>();
|
||||
test_is_object<const int*>();
|
||||
test_is_object<Enum>();
|
||||
test_is_object<Empty>();
|
||||
test_is_object<bit_zero>();
|
||||
test_is_object<NotEmpty>();
|
||||
test_is_object<Abstract>();
|
||||
test_is_object<FunctionPtr>();
|
||||
test_is_object<int Empty::*>();
|
||||
test_is_object<void (Empty::*)(int)>();
|
||||
|
||||
test_is_not_object<void>();
|
||||
test_is_not_object<int&>();
|
||||
test_is_not_object<int&&>();
|
||||
test_is_not_object<int(int)>();
|
||||
}
|
@@ -0,0 +1,100 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// type_traits
|
||||
|
||||
// is_reference
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void test_is_reference()
|
||||
{
|
||||
static_assert( std::is_reference<T>::value, "");
|
||||
static_assert( std::is_reference<const T>::value, "");
|
||||
static_assert( std::is_reference<volatile T>::value, "");
|
||||
static_assert( std::is_reference<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_reference_v<T>, "");
|
||||
static_assert( std::is_reference_v<const T>, "");
|
||||
static_assert( std::is_reference_v<volatile T>, "");
|
||||
static_assert( std::is_reference_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_is_not_reference()
|
||||
{
|
||||
static_assert(!std::is_reference<T>::value, "");
|
||||
static_assert(!std::is_reference<const T>::value, "");
|
||||
static_assert(!std::is_reference<volatile T>::value, "");
|
||||
static_assert(!std::is_reference<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_reference_v<T>, "");
|
||||
static_assert(!std::is_reference_v<const T>, "");
|
||||
static_assert(!std::is_reference_v<volatile T>, "");
|
||||
static_assert(!std::is_reference_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Empty
|
||||
{
|
||||
};
|
||||
|
||||
class NotEmpty
|
||||
{
|
||||
virtual ~NotEmpty();
|
||||
};
|
||||
|
||||
union Union {};
|
||||
|
||||
struct bit_zero
|
||||
{
|
||||
int : 0;
|
||||
};
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual ~Abstract() = 0;
|
||||
};
|
||||
|
||||
enum Enum {zero, one};
|
||||
|
||||
typedef void (*FunctionPtr)();
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
test_is_reference<int&>();
|
||||
#if TEST_STD_VER >= 11
|
||||
test_is_reference<int&&>();
|
||||
#endif
|
||||
|
||||
test_is_not_reference<std::nullptr_t>();
|
||||
test_is_not_reference<void>();
|
||||
test_is_not_reference<int>();
|
||||
test_is_not_reference<double>();
|
||||
test_is_not_reference<char[3]>();
|
||||
test_is_not_reference<char[]>();
|
||||
test_is_not_reference<void *>();
|
||||
test_is_not_reference<FunctionPtr>();
|
||||
test_is_not_reference<Union>();
|
||||
test_is_not_reference<Empty>();
|
||||
test_is_not_reference<bit_zero>();
|
||||
test_is_not_reference<int*>();
|
||||
test_is_not_reference<const int*>();
|
||||
test_is_not_reference<Enum>();
|
||||
test_is_not_reference<NotEmpty>();
|
||||
test_is_not_reference<Abstract>();
|
||||
test_is_not_reference<int(int)>();
|
||||
test_is_not_reference<int Empty::*>();
|
||||
test_is_not_reference<void (Empty::*)(int)>();
|
||||
|
||||
}
|
@@ -0,0 +1,110 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// type_traits
|
||||
|
||||
// is_scalar
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void test_is_scalar()
|
||||
{
|
||||
static_assert( std::is_scalar<T>::value, "");
|
||||
static_assert( std::is_scalar<const T>::value, "");
|
||||
static_assert( std::is_scalar<volatile T>::value, "");
|
||||
static_assert( std::is_scalar<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_scalar_v<T>, "");
|
||||
static_assert( std::is_scalar_v<const T>, "");
|
||||
static_assert( std::is_scalar_v<volatile T>, "");
|
||||
static_assert( std::is_scalar_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_is_not_scalar()
|
||||
{
|
||||
static_assert(!std::is_scalar<T>::value, "");
|
||||
static_assert(!std::is_scalar<const T>::value, "");
|
||||
static_assert(!std::is_scalar<volatile T>::value, "");
|
||||
static_assert(!std::is_scalar<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_scalar_v<T>, "");
|
||||
static_assert(!std::is_scalar_v<const T>, "");
|
||||
static_assert(!std::is_scalar_v<volatile T>, "");
|
||||
static_assert(!std::is_scalar_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Empty
|
||||
{
|
||||
};
|
||||
|
||||
class NotEmpty
|
||||
{
|
||||
virtual ~NotEmpty();
|
||||
};
|
||||
|
||||
union Union {};
|
||||
|
||||
struct bit_zero
|
||||
{
|
||||
int : 0;
|
||||
};
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual ~Abstract() = 0;
|
||||
};
|
||||
|
||||
enum Enum {zero, one};
|
||||
|
||||
typedef void (*FunctionPtr)();
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
// Arithmetic types (3.9.1), enumeration types, pointer types, pointer to member types (3.9.2),
|
||||
// std::nullptr_t, and cv-qualified versions of these types (3.9.3)
|
||||
// are collectively called scalar types.
|
||||
|
||||
test_is_scalar<std::nullptr_t>();
|
||||
test_is_scalar<short>();
|
||||
test_is_scalar<unsigned short>();
|
||||
test_is_scalar<int>();
|
||||
test_is_scalar<unsigned int>();
|
||||
test_is_scalar<long>();
|
||||
test_is_scalar<unsigned long>();
|
||||
test_is_scalar<bool>();
|
||||
test_is_scalar<char>();
|
||||
test_is_scalar<signed char>();
|
||||
test_is_scalar<unsigned char>();
|
||||
test_is_scalar<wchar_t>();
|
||||
test_is_scalar<double>();
|
||||
test_is_scalar<int*>();
|
||||
test_is_scalar<const int*>();
|
||||
test_is_scalar<int Empty::*>();
|
||||
test_is_scalar<void (Empty::*)(int)>();
|
||||
test_is_scalar<Enum>();
|
||||
test_is_scalar<FunctionPtr>();
|
||||
|
||||
test_is_not_scalar<void>();
|
||||
test_is_not_scalar<int&>();
|
||||
test_is_not_scalar<int&&>();
|
||||
test_is_not_scalar<char[3]>();
|
||||
test_is_not_scalar<char[]>();
|
||||
test_is_not_scalar<Union>();
|
||||
test_is_not_scalar<Empty>();
|
||||
test_is_not_scalar<bit_zero>();
|
||||
test_is_not_scalar<NotEmpty>();
|
||||
test_is_not_scalar<Abstract>();
|
||||
test_is_not_scalar<int(int)>();
|
||||
}
|
@@ -12,6 +12,7 @@
|
||||
// is_abstract
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void test_is_abstract()
|
||||
@@ -20,6 +21,12 @@ void test_is_abstract()
|
||||
static_assert( std::is_abstract<const T>::value, "");
|
||||
static_assert( std::is_abstract<volatile T>::value, "");
|
||||
static_assert( std::is_abstract<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_abstract_v<T>, "");
|
||||
static_assert( std::is_abstract_v<const T>, "");
|
||||
static_assert( std::is_abstract_v<volatile T>, "");
|
||||
static_assert( std::is_abstract_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@@ -29,6 +36,12 @@ void test_is_not_abstract()
|
||||
static_assert(!std::is_abstract<const T>::value, "");
|
||||
static_assert(!std::is_abstract<volatile T>::value, "");
|
||||
static_assert(!std::is_abstract<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_abstract_v<T>, "");
|
||||
static_assert(!std::is_abstract_v<const T>, "");
|
||||
static_assert(!std::is_abstract_v<volatile T>, "");
|
||||
static_assert(!std::is_abstract_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Empty
|
||||
|
@@ -20,6 +20,12 @@ void test_is_const()
|
||||
static_assert( std::is_const<const T>::value, "");
|
||||
static_assert(!std::is_const<volatile T>::value, "");
|
||||
static_assert( std::is_const<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_const_v<T>::value, "");
|
||||
static_assert( std::is_const_v<const T>, "");
|
||||
static_assert(!std::is_const_v<volatile T>, "");
|
||||
static_assert( std::is_const_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@@ -20,6 +20,12 @@ void test_is_empty()
|
||||
static_assert( std::is_empty<const T>::value, "");
|
||||
static_assert( std::is_empty<volatile T>::value, "");
|
||||
static_assert( std::is_empty<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_empty_v<T>, "");
|
||||
static_assert( std::is_empty_v<const T>, "");
|
||||
static_assert( std::is_empty_v<volatile T>, "");
|
||||
static_assert( std::is_empty_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@@ -29,6 +35,12 @@ void test_is_not_empty()
|
||||
static_assert(!std::is_empty<const T>::value, "");
|
||||
static_assert(!std::is_empty<volatile T>::value, "");
|
||||
static_assert(!std::is_empty<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_empty_v<T>, "");
|
||||
static_assert(!std::is_empty_v<const T>, "");
|
||||
static_assert(!std::is_empty_v<volatile T>, "");
|
||||
static_assert(!std::is_empty_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Empty
|
||||
|
@@ -26,6 +26,12 @@ void test_is_final()
|
||||
static_assert( std::is_final<const T>::value, "");
|
||||
static_assert( std::is_final<volatile T>::value, "");
|
||||
static_assert( std::is_final<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_final_v<T>, "");
|
||||
static_assert( std::is_final_v<const T>, "");
|
||||
static_assert( std::is_final_v<volatile T>, "");
|
||||
static_assert( std::is_final_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@@ -35,6 +41,12 @@ void test_is_not_final()
|
||||
static_assert(!std::is_final<const T>::value, "");
|
||||
static_assert(!std::is_final<volatile T>::value, "");
|
||||
static_assert(!std::is_final<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_final_v<T>, "");
|
||||
static_assert(!std::is_final_v<const T>, "");
|
||||
static_assert(!std::is_final_v<volatile T>, "");
|
||||
static_assert(!std::is_final_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
int main ()
|
||||
|
@@ -17,12 +17,26 @@ template <class T>
|
||||
void test_is_literal_type()
|
||||
{
|
||||
static_assert( std::is_literal_type<T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_literal_type_v<T>, "");
|
||||
// static_assert( std::is_final_v<T>, "");
|
||||
// static_assert( std::is_final_v<const T>, "");
|
||||
// static_assert( std::is_final_v<volatile T>, "");
|
||||
// static_assert( std::is_final_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_is_not_literal_type()
|
||||
{
|
||||
static_assert(!std::is_literal_type<T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_literal_type_v<T>, "");
|
||||
// static_assert( std::is_final_v<T>, "");
|
||||
// static_assert( std::is_final_v<const T>, "");
|
||||
// static_assert( std::is_final_v<volatile T>, "");
|
||||
// static_assert( std::is_final_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
struct A
|
||||
|
@@ -20,6 +20,12 @@ void test_is_pod()
|
||||
static_assert( std::is_pod<const T>::value, "");
|
||||
static_assert( std::is_pod<volatile T>::value, "");
|
||||
static_assert( std::is_pod<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_pod_v<T>, "");
|
||||
static_assert( std::is_pod_v<const T>, "");
|
||||
static_assert( std::is_pod_v<volatile T>, "");
|
||||
static_assert( std::is_pod_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@@ -29,6 +35,12 @@ void test_is_not_pod()
|
||||
static_assert(!std::is_pod<const T>::value, "");
|
||||
static_assert(!std::is_pod<volatile T>::value, "");
|
||||
static_assert(!std::is_pod<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_pod_v<T>, "");
|
||||
static_assert( std::is_pod_v<const T>, "");
|
||||
static_assert( std::is_pod_v<volatile T>, "");
|
||||
static_assert( std::is_pod_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Class
|
||||
|
@@ -20,6 +20,12 @@ void test_is_polymorphic()
|
||||
static_assert( std::is_polymorphic<const T>::value, "");
|
||||
static_assert( std::is_polymorphic<volatile T>::value, "");
|
||||
static_assert( std::is_polymorphic<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_polymorphic_v<T>, "");
|
||||
static_assert( std::is_polymorphic_v<const T>, "");
|
||||
static_assert( std::is_polymorphic_v<volatile T>, "");
|
||||
static_assert( std::is_polymorphic_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@@ -29,6 +35,12 @@ void test_is_not_polymorphic()
|
||||
static_assert(!std::is_polymorphic<const T>::value, "");
|
||||
static_assert(!std::is_polymorphic<volatile T>::value, "");
|
||||
static_assert(!std::is_polymorphic<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_polymorphic_v<T>, "");
|
||||
static_assert(!std::is_polymorphic_v<const T>, "");
|
||||
static_assert(!std::is_polymorphic_v<volatile T>, "");
|
||||
static_assert(!std::is_polymorphic_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Empty
|
||||
|
@@ -20,6 +20,12 @@ void test_is_signed()
|
||||
static_assert( std::is_signed<const T>::value, "");
|
||||
static_assert( std::is_signed<volatile T>::value, "");
|
||||
static_assert( std::is_signed<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_signed_v<T>, "");
|
||||
static_assert( std::is_signed_v<const T>, "");
|
||||
static_assert( std::is_signed_v<volatile T>, "");
|
||||
static_assert( std::is_signed_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@@ -29,6 +35,12 @@ void test_is_not_signed()
|
||||
static_assert(!std::is_signed<const T>::value, "");
|
||||
static_assert(!std::is_signed<volatile T>::value, "");
|
||||
static_assert(!std::is_signed<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_signed_v<T>, "");
|
||||
static_assert(!std::is_signed_v<const T>, "");
|
||||
static_assert(!std::is_signed_v<volatile T>, "");
|
||||
static_assert(!std::is_signed_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
class Class
|
||||
|
@@ -20,6 +20,12 @@ void test_is_standard_layout()
|
||||
static_assert( std::is_standard_layout<const T>::value, "");
|
||||
static_assert( std::is_standard_layout<volatile T>::value, "");
|
||||
static_assert( std::is_standard_layout<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_standard_layout_v<T>, "");
|
||||
static_assert( std::is_standard_layout_v<const T>, "");
|
||||
static_assert( std::is_standard_layout_v<volatile T>, "");
|
||||
static_assert( std::is_standard_layout_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@@ -29,6 +35,12 @@ void test_is_not_standard_layout()
|
||||
static_assert(!std::is_standard_layout<const T>::value, "");
|
||||
static_assert(!std::is_standard_layout<volatile T>::value, "");
|
||||
static_assert(!std::is_standard_layout<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_standard_layout_v<T>, "");
|
||||
static_assert(!std::is_standard_layout_v<const T>, "");
|
||||
static_assert(!std::is_standard_layout_v<volatile T>, "");
|
||||
static_assert(!std::is_standard_layout_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T1, class T2>
|
||||
|
@@ -20,6 +20,12 @@ void test_is_trivial()
|
||||
static_assert( std::is_trivial<const T>::value, "");
|
||||
static_assert( std::is_trivial<volatile T>::value, "");
|
||||
static_assert( std::is_trivial<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_trivial_v<T>, "");
|
||||
static_assert( std::is_trivial_v<const T>, "");
|
||||
static_assert( std::is_trivial_v<volatile T>, "");
|
||||
static_assert( std::is_trivial_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@@ -29,6 +35,12 @@ void test_is_not_trivial()
|
||||
static_assert(!std::is_trivial<const T>::value, "");
|
||||
static_assert(!std::is_trivial<volatile T>::value, "");
|
||||
static_assert(!std::is_trivial<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_trivial_v<T>, "");
|
||||
static_assert(!std::is_trivial_v<const T>, "");
|
||||
static_assert(!std::is_trivial_v<volatile T>, "");
|
||||
static_assert(!std::is_trivial_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
struct A {};
|
||||
|
@@ -21,6 +21,12 @@ void test_is_trivially_copyable()
|
||||
static_assert( std::is_trivially_copyable<const T>::value, "");
|
||||
static_assert(!std::is_trivially_copyable<volatile T>::value, "");
|
||||
static_assert(!std::is_trivially_copyable<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert( std::is_trivially_copyable_v<T>, "");
|
||||
static_assert( std::is_trivially_copyable_v<const T>, "");
|
||||
static_assert(!std::is_trivially_copyable_v<volatile T>, "");
|
||||
static_assert(!std::is_trivially_copyable_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@@ -30,6 +36,12 @@ void test_is_not_trivially_copyable()
|
||||
static_assert(!std::is_trivially_copyable<const T>::value, "");
|
||||
static_assert(!std::is_trivially_copyable<volatile T>::value, "");
|
||||
static_assert(!std::is_trivially_copyable<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_trivially_copyable_v<T>, "");
|
||||
static_assert(!std::is_trivially_copyable_v<const T>, "");
|
||||
static_assert(!std::is_trivially_copyable_v<volatile T>, "");
|
||||
static_assert(!std::is_trivially_copyable_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
struct A
|
||||
|
@@ -20,6 +20,12 @@ void test_is_unsigned()
|
||||
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>
|
||||
@@ -29,6 +35,12 @@ void test_is_not_unsigned()
|
||||
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
|
||||
|
@@ -20,6 +20,12 @@ void test_is_volatile()
|
||||
static_assert(!std::is_volatile<const T>::value, "");
|
||||
static_assert( std::is_volatile<volatile T>::value, "");
|
||||
static_assert( std::is_volatile<const volatile T>::value, "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(!std::is_volatile_v<T>, "");
|
||||
static_assert(!std::is_volatile_v<const T>, "");
|
||||
static_assert( std::is_volatile_v<volatile T>, "");
|
||||
static_assert( std::is_volatile_v<const volatile T>, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
int main()
|
||||
|
Reference in New Issue
Block a user