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_COPY_CV_H
10 #define _LIBCPP___TYPE_TRAITS_COPY_CV_H
11 
12 #include <__config>
13 #include <__type_traits/add_const.h>
14 #include <__type_traits/add_cv.h>
15 #include <__type_traits/add_volatile.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 // Let COPYCV(FROM, TO) be an alias for type TO with the addition of FROM's
24 // top-level cv-qualifiers.
25 template <class _From, class _To>
26 struct __copy_cv {
27   using type = _To;
28 };
29 
30 template <class _From, class _To>
31 struct __copy_cv<const _From, _To> {
32   using type = typename add_const<_To>::type;
33 };
34 
35 template <class _From, class _To>
36 struct __copy_cv<volatile _From, _To> {
37   using type = typename add_volatile<_To>::type;
38 };
39 
40 template <class _From, class _To>
41 struct __copy_cv<const volatile _From, _To> {
42   using type = typename add_cv<_To>::type;
43 };
44 
45 template <class _From, class _To>
46 using __copy_cv_t = typename __copy_cv<_From, _To>::type;
47 
48 _LIBCPP_END_NAMESPACE_STD
49 
50 #endif // _LIBCPP___TYPE_TRAITS_COPY_CV_H
51