xref: /freebsd/contrib/llvm-project/libcxx/include/__type_traits/copy_cv.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
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 
14 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15 #  pragma GCC system_header
16 #endif
17 
18 _LIBCPP_BEGIN_NAMESPACE_STD
19 
20 // Let COPYCV(FROM, TO) be an alias for type TO with the addition of FROM's
21 // top-level cv-qualifiers.
22 template <class _From>
23 struct __copy_cv {
24   template <class _To>
25   using __apply = _To;
26 };
27 
28 template <class _From>
29 struct __copy_cv<const _From> {
30   template <class _To>
31   using __apply = const _To;
32 };
33 
34 template <class _From>
35 struct __copy_cv<volatile _From> {
36   template <class _To>
37   using __apply = volatile _To;
38 };
39 
40 template <class _From>
41 struct __copy_cv<const volatile _From> {
42   template <class _To>
43   using __apply = const volatile _To;
44 };
45 
46 template <class _From, class _To>
47 using __copy_cv_t = typename __copy_cv<_From>::template __apply<_To>;
48 
49 _LIBCPP_END_NAMESPACE_STD
50 
51 #endif // _LIBCPP___TYPE_TRAITS_COPY_CV_H
52