| 1 | // { dg-do compile { target c++11 } } |
| 2 | |
| 3 | // 2005-01-24 Paolo Carlini <[email protected]> |
| 4 | // |
| 5 | // Copyright (C) 2005-2025 Free Software Foundation, Inc. |
| 6 | // |
| 7 | // This file is part of the GNU ISO C++ Library. This library is free |
| 8 | // software; you can redistribute it and/or modify it under the |
| 9 | // terms of the GNU General Public License as published by the |
| 10 | // Free Software Foundation; either version 3, or (at your option) |
| 11 | // any later version. |
| 12 | // |
| 13 | // This library is distributed in the hope that it will be useful, |
| 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | // GNU General Public License for more details. |
| 17 | // |
| 18 | // You should have received a copy of the GNU General Public License along |
| 19 | // with this library; see the file COPYING3. If not see |
| 20 | // <http://www.gnu.org/licenses/>. |
| 21 | |
| 22 | #include <type_traits> |
| 23 | #include <testsuite_tr1.h> |
| 24 | |
| 25 | void test01() |
| 26 | { |
| 27 | using std::is_signed; |
| 28 | using namespace __gnu_test; |
| 29 | |
| 30 | static_assert(test_category<is_signed, void>(false), ""); |
| 31 | |
| 32 | static_assert(test_category<is_signed, char>(char(-1) < char(0)), ""); |
| 33 | static_assert(test_category<is_signed, signed char>(true), ""); |
| 34 | static_assert(test_category<is_signed, unsigned char>(false), ""); |
| 35 | static_assert(test_category<is_signed, wchar_t> |
| 36 | (wchar_t(-1) < wchar_t(0)), ""); |
| 37 | static_assert(test_category<is_signed, short>(true), ""); |
| 38 | static_assert(test_category<is_signed, unsigned short>(false), ""); |
| 39 | static_assert(test_category<is_signed, int>(true), ""); |
| 40 | static_assert(test_category<is_signed, unsigned int>(false), ""); |
| 41 | static_assert(test_category<is_signed, long>(true), ""); |
| 42 | static_assert(test_category<is_signed, unsigned long>(false), ""); |
| 43 | static_assert(test_category<is_signed, long long>(true), ""); |
| 44 | static_assert(test_category<is_signed, unsigned long long>(false), ""); |
| 45 | |
| 46 | static_assert(test_category<is_signed, float>(true), ""); |
| 47 | static_assert(test_category<is_signed, double>(true), ""); |
| 48 | static_assert(test_category<is_signed, long double>(true), ""); |
| 49 | |
| 50 | #ifndef __STRICT_ANSI__ |
| 51 | // GNU Extensions. |
| 52 | #ifdef __SIZEOF_INT128__ |
| 53 | static_assert(test_category<is_signed, __int128>(true), ""); |
| 54 | static_assert(test_category<is_signed, unsigned __int128>(false), ""); |
| 55 | #endif |
| 56 | |
| 57 | #ifdef _GLIBCXX_USE_FLOAT128 |
| 58 | static_assert(test_category<is_signed, __float128>(true), ""); |
| 59 | #endif |
| 60 | #endif |
| 61 | |
| 62 | // Sanity check. |
| 63 | static_assert(test_category<is_signed, ClassType>(false), ""); |
| 64 | } |