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 _LIBCPP___TYPE_TRAITS_APPLY_CV_H 10 #define _LIBCPP___TYPE_TRAITS_APPLY_CV_H 11 12 #include <__config> 13 #include <__type_traits/is_const.h> 14 #include <__type_traits/is_volatile.h> 15 #include <__type_traits/remove_reference.h> 16 17 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 18 # pragma GCC system_header 19 #endif 20 21 _LIBCPP_BEGIN_NAMESPACE_STD 22 23 template <class _Tp, 24 bool = is_const<__libcpp_remove_reference_t<_Tp> >::value, 25 bool = is_volatile<__libcpp_remove_reference_t<_Tp> >::value> 26 struct __apply_cv_impl { 27 template <class _Up> 28 using __apply _LIBCPP_NODEBUG = _Up; 29 }; 30 31 template <class _Tp> 32 struct __apply_cv_impl<_Tp, true, false> { 33 template <class _Up> 34 using __apply _LIBCPP_NODEBUG = const _Up; 35 }; 36 37 template <class _Tp> 38 struct __apply_cv_impl<_Tp, false, true> { 39 template <class _Up> 40 using __apply _LIBCPP_NODEBUG = volatile _Up; 41 }; 42 43 template <class _Tp> 44 struct __apply_cv_impl<_Tp, true, true> { 45 template <class _Up> 46 using __apply _LIBCPP_NODEBUG = const volatile _Up; 47 }; 48 49 template <class _Tp> 50 struct __apply_cv_impl<_Tp&, false, false> { 51 template <class _Up> 52 using __apply _LIBCPP_NODEBUG = _Up&; 53 }; 54 55 template <class _Tp> 56 struct __apply_cv_impl<_Tp&, true, false> { 57 template <class _Up> 58 using __apply _LIBCPP_NODEBUG = const _Up&; 59 }; 60 61 template <class _Tp> 62 struct __apply_cv_impl<_Tp&, false, true> { 63 template <class _Up> 64 using __apply _LIBCPP_NODEBUG = volatile _Up&; 65 }; 66 67 template <class _Tp> 68 struct __apply_cv_impl<_Tp&, true, true> { 69 template <class _Up> 70 using __apply _LIBCPP_NODEBUG = const volatile _Up&; 71 }; 72 73 template <class _Tp, class _Up> 74 using __apply_cv_t _LIBCPP_NODEBUG = typename __apply_cv_impl<_Tp>::template __apply<_Up>; 75 76 _LIBCPP_END_NAMESPACE_STD 77 78 #endif // _LIBCPP___TYPE_TRAITS_APPLY_CV_H 79