Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / include / __iterator / readable_traits.h
blob9e101fc28a6f1d97006c4d41d3fb02ab66d51f50
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___ITERATOR_READABLE_TRAITS_H
11 #define _LIBCPP___ITERATOR_READABLE_TRAITS_H
13 #include <__concepts/same_as.h>
14 #include <__config>
15 #include <__type_traits/conditional.h>
16 #include <__type_traits/is_array.h>
17 #include <__type_traits/is_object.h>
18 #include <__type_traits/is_primary_template.h>
19 #include <__type_traits/remove_cv.h>
20 #include <__type_traits/remove_cvref.h>
21 #include <__type_traits/remove_extent.h>
23 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24 # pragma GCC system_header
25 #endif
27 _LIBCPP_BEGIN_NAMESPACE_STD
29 #if _LIBCPP_STD_VER >= 20
31 // [readable.traits]
32 template<class> struct __cond_value_type {};
34 template<class _Tp>
35 requires is_object_v<_Tp>
36 struct __cond_value_type<_Tp> { using value_type = remove_cv_t<_Tp>; };
38 template<class _Tp>
39 concept __has_member_value_type = requires { typename _Tp::value_type; };
41 template<class _Tp>
42 concept __has_member_element_type = requires { typename _Tp::element_type; };
44 template<class> struct indirectly_readable_traits {};
46 template<class _Ip>
47 requires is_array_v<_Ip>
48 struct indirectly_readable_traits<_Ip> {
49 using value_type = remove_cv_t<remove_extent_t<_Ip>>;
52 template<class _Ip>
53 struct indirectly_readable_traits<const _Ip> : indirectly_readable_traits<_Ip> {};
55 template<class _Tp>
56 struct indirectly_readable_traits<_Tp*> : __cond_value_type<_Tp> {};
58 template<__has_member_value_type _Tp>
59 struct indirectly_readable_traits<_Tp>
60 : __cond_value_type<typename _Tp::value_type> {};
62 template<__has_member_element_type _Tp>
63 struct indirectly_readable_traits<_Tp>
64 : __cond_value_type<typename _Tp::element_type> {};
66 template<__has_member_value_type _Tp>
67 requires __has_member_element_type<_Tp>
68 struct indirectly_readable_traits<_Tp> {};
70 template<__has_member_value_type _Tp>
71 requires __has_member_element_type<_Tp> &&
72 same_as<remove_cv_t<typename _Tp::element_type>,
73 remove_cv_t<typename _Tp::value_type>>
74 struct indirectly_readable_traits<_Tp>
75 : __cond_value_type<typename _Tp::value_type> {};
77 #endif // _LIBCPP_STD_VER >= 20
79 _LIBCPP_END_NAMESPACE_STD
81 #endif // _LIBCPP___ITERATOR_READABLE_TRAITS_H