1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 #include <test_macros.h>
13 // UNSUPPORTED: c++98, c++03, c++11, c++14
15 // template <class IntegerType>
16 // constexpr IntegerType to_integer(byte b) noexcept;
17 // This function shall not participate in overload resolution unless
18 // is_integral_v<IntegerType> is true.
21 constexpr std::byte b1{static_cast<std::byte>(1)};
22 constexpr std::byte b3{static_cast<std::byte>(3)};
24 static_assert(noexcept(std::to_integer<int>(b1)), "" );
25 static_assert(std::is_same<int, decltype(std::to_integer<int>(b1))>::value, "" );
26 static_assert(std::is_same<long, decltype(std::to_integer<long>(b1))>::value, "" );
27 static_assert(std::is_same<unsigned short, decltype(std::to_integer<unsigned short>(b1))>::value, "" );
29 static_assert(std::to_integer<int>(b1) == 1, "");
30 static_assert(std::to_integer<int>(b3) == 3, "");