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