[MemProf] Templatize CallStackRadixTreeBuilder (NFC) (#117014)
[llvm-project.git] / libcxx / test / std / containers / views / mdspan / ConvertibleToIntegral.h
blob0ca5c330a390e4b9b056ec7157bddd19eb6a4c5b
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 //===----------------------------------------------------------------------===//
9 #ifndef TEST_STD_CONTAINERS_VIEWS_MDSPAN_CONVERTIBLE_TO_INTEGRAL_H
10 #define TEST_STD_CONTAINERS_VIEWS_MDSPAN_CONVERTIBLE_TO_INTEGRAL_H
12 struct IntType {
13 int val;
14 constexpr IntType() = default;
15 constexpr IntType(int v) noexcept : val(v) {}
17 constexpr bool operator==(const IntType& rhs) const { return val == rhs.val; }
18 constexpr operator int() const noexcept { return val; }
19 constexpr operator unsigned char() const { return static_cast<unsigned char>(val); }
20 constexpr operator signed char() const noexcept { return static_cast<signed char>(val); }
23 // only non-const convertible
24 struct IntTypeNC {
25 int val;
26 constexpr IntTypeNC() = default;
27 constexpr IntTypeNC(int v) noexcept : val(v) {}
29 constexpr bool operator==(const IntType& rhs) const { return val == rhs.val; }
30 constexpr operator int() noexcept { return val; }
31 constexpr operator unsigned() { return static_cast<unsigned>(val); }
32 constexpr operator char() noexcept { return static_cast<char>(val); }
35 // weird configurability of convertibility to int
36 template<bool conv_c, bool conv_nc, bool ctor_nt_c, bool ctor_nt_nc>
37 struct IntConfig {
38 int val;
39 constexpr explicit IntConfig(int val_):val(val_){}
40 constexpr operator int() noexcept(ctor_nt_nc) requires(conv_nc) { return val; }
41 constexpr operator int() const noexcept(ctor_nt_c) requires(conv_c) { return val; }
44 #endif // TEST_STD_CONTAINERS_VIEWS_MDSPAN_CONVERTIBLE_TO_INTEGRAL_H