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 {
28     using type = _To;
29 };
30 
31 template <class _From, class _To>
32 struct __copy_cv<const _From, _To>
33 {
34     using type = typename add_const<_To>::type;
35 };
36 
37 template <class _From, class _To>
38 struct __copy_cv<volatile _From, _To>
39 {
40     using type = typename add_volatile<_To>::type;
41 };
42 
43 template <class _From, class _To>
44 struct __copy_cv<const volatile _From, _To>
45 {
46     using type = typename add_cv<_To>::type;
47 };
48 
49 template <class _From, class _To>
50 using __copy_cv_t = typename __copy_cv<_From, _To>::type;
51 
52 _LIBCPP_END_NAMESPACE_STD
53 
54 #endif // _LIBCPP___TYPE_TRAITS_COPY_CV_H
55