69 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// is_pod12 13// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS14 15#include <type_traits>16#include "test_macros.h"17 18template <class T>19void test_is_pod()20{21 static_assert( std::is_pod<T>::value, "");22 static_assert( std::is_pod<const T>::value, "");23 static_assert( std::is_pod<volatile T>::value, "");24 static_assert( std::is_pod<const volatile T>::value, "");25#if TEST_STD_VER > 1426 static_assert( std::is_pod_v<T>, "");27 static_assert( std::is_pod_v<const T>, "");28 static_assert( std::is_pod_v<volatile T>, "");29 static_assert( std::is_pod_v<const volatile T>, "");30#endif31}32 33template <class T>34void test_is_not_pod()35{36 static_assert(!std::is_pod<T>::value, "");37 static_assert(!std::is_pod<const T>::value, "");38 static_assert(!std::is_pod<volatile T>::value, "");39 static_assert(!std::is_pod<const volatile T>::value, "");40#if TEST_STD_VER > 1441 static_assert(!std::is_pod_v<T>, "");42 static_assert(!std::is_pod_v<const T>, "");43 static_assert(!std::is_pod_v<volatile T>, "");44 static_assert(!std::is_pod_v<const volatile T>, "");45#endif46}47 48class Class49{50public:51 ~Class();52};53 54int main(int, char**)55{56 test_is_not_pod<void>();57 test_is_not_pod<int&>();58 test_is_not_pod<Class>();59 60 test_is_pod<int>();61 test_is_pod<double>();62 test_is_pod<int*>();63 test_is_pod<const int*>();64 test_is_pod<char[3]>();65 test_is_pod<char[]>();66 67 return 0;68}69