xref: /llvm-project/libcxx/test/std/concepts/concepts.lang/concepts.arithmetic/arithmetic.h (revision 480cd780d63fd9c658cc2f51d0c54416b8b1a5c3)
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-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LIBCXX_TEST_CONCEPTS_LANG_CONCEPTS_ARITHMETIC_H_
10 #define LIBCXX_TEST_CONCEPTS_LANG_CONCEPTS_ARITHMETIC_H_
11 
12 #include <concepts>
13 
14 // This overload should never be called. It exists solely to force subsumption.
15 template <std::integral I>
CheckSubsumption(I)16 constexpr bool CheckSubsumption(I) {
17   return false;
18 }
19 
20 // clang-format off
21 template <std::integral I>
22 requires std::signed_integral<I> && (!std::unsigned_integral<I>)
CheckSubsumption(I)23 constexpr bool CheckSubsumption(I) {
24   return std::is_signed_v<I>;
25 }
26 
27 template <std::integral I>
28 requires std::unsigned_integral<I> && (!std::signed_integral<I>)
CheckSubsumption(I)29 constexpr bool CheckSubsumption(I) {
30   return std::is_unsigned_v<I>;
31 }
32 // clang-format on
33 
34 enum ClassicEnum { a, b, c };
35 enum class ScopedEnum { x, y, z };
36 struct EmptyStruct {};
37 
38 #endif // LIBCXX_TEST_CONCEPTS_LANG_CONCEPTS_ARITHMETIC_H_
39