xref: /llvm-project/libcxx/test/std/concepts/concepts.lang/concepts.arithmetic/arithmetic.h (revision 480cd780d63fd9c658cc2f51d0c54416b8b1a5c3)
124dd2d2fSChristopher Di Bella //===----------------------------------------------------------------------===//
224dd2d2fSChristopher Di Bella //
324dd2d2fSChristopher Di Bella // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
424dd2d2fSChristopher Di Bella // See https://llvm.org/LICENSE.txt for license information.
524dd2d2fSChristopher Di Bella // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
624dd2d2fSChristopher Di Bella //
724dd2d2fSChristopher Di Bella //===----------------------------------------------------------------------===//
8*480cd780SLouis Dionne 
924dd2d2fSChristopher Di Bella #ifndef LIBCXX_TEST_CONCEPTS_LANG_CONCEPTS_ARITHMETIC_H_
1024dd2d2fSChristopher Di Bella #define LIBCXX_TEST_CONCEPTS_LANG_CONCEPTS_ARITHMETIC_H_
1124dd2d2fSChristopher Di Bella 
1224dd2d2fSChristopher Di Bella #include <concepts>
1324dd2d2fSChristopher Di Bella 
1424dd2d2fSChristopher Di Bella // This overload should never be called. It exists solely to force subsumption.
1524dd2d2fSChristopher Di Bella template <std::integral I>
CheckSubsumption(I)1688b73a98SLouis Dionne constexpr bool CheckSubsumption(I) {
1724dd2d2fSChristopher Di Bella   return false;
1824dd2d2fSChristopher Di Bella }
1924dd2d2fSChristopher Di Bella 
2024dd2d2fSChristopher Di Bella // clang-format off
2124dd2d2fSChristopher Di Bella template <std::integral I>
2224dd2d2fSChristopher Di Bella requires std::signed_integral<I> && (!std::unsigned_integral<I>)
CheckSubsumption(I)2388b73a98SLouis Dionne constexpr bool CheckSubsumption(I) {
2424dd2d2fSChristopher Di Bella   return std::is_signed_v<I>;
2524dd2d2fSChristopher Di Bella }
2624dd2d2fSChristopher Di Bella 
2724dd2d2fSChristopher Di Bella template <std::integral I>
2824dd2d2fSChristopher Di Bella requires std::unsigned_integral<I> && (!std::signed_integral<I>)
CheckSubsumption(I)2988b73a98SLouis Dionne constexpr bool CheckSubsumption(I) {
3024dd2d2fSChristopher Di Bella   return std::is_unsigned_v<I>;
3124dd2d2fSChristopher Di Bella }
3224dd2d2fSChristopher Di Bella // clang-format on
3324dd2d2fSChristopher Di Bella 
3424dd2d2fSChristopher Di Bella enum ClassicEnum { a, b, c };
3524dd2d2fSChristopher Di Bella enum class ScopedEnum { x, y, z };
3624dd2d2fSChristopher Di Bella struct EmptyStruct {};
3724dd2d2fSChristopher Di Bella 
3824dd2d2fSChristopher Di Bella #endif // LIBCXX_TEST_CONCEPTS_LANG_CONCEPTS_ARITHMETIC_H_
39