brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · f312aca Raw
53 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// integral_constant12 13#include <type_traits>14#include <cassert>15 16#include "test_macros.h"17 18int main(int, char**)19{20    typedef std::integral_constant<int, 5> _5;21    static_assert(_5::value == 5, "");22    static_assert((std::is_same<_5::value_type, int>::value), "");23    static_assert((std::is_same<_5::type, _5>::value), "");24#if TEST_STD_VER >= 1125    static_assert((_5() == 5), "");26#endif27    assert(_5() == 5);28 29 30#if TEST_STD_VER > 1131    static_assert ( _5{}() == 5, "" );32    static_assert ( std::true_type{}(), "" );33#endif34 35    static_assert(std::false_type::value == false, "");36    static_assert((std::is_same<std::false_type::value_type, bool>::value), "");37    static_assert((std::is_same<std::false_type::type, std::false_type>::value), "");38 39    static_assert(std::true_type::value == true, "");40    static_assert((std::is_same<std::true_type::value_type, bool>::value), "");41    static_assert((std::is_same<std::true_type::type, std::true_type>::value), "");42 43    std::false_type f1;44    std::false_type f2 = f1;45    assert(!f2);46 47    std::true_type t1;48    std::true_type t2 = t1;49    assert(t2);50 51  return 0;52}53