xref: /freebsd/contrib/llvm-project/libcxx/include/__utility/as_const.h (revision 848ee2a3a8b47c9905fc51fefcf60eb371edbb98)
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___UTILITY_AS_CONST_H
10 #define _LIBCPP___UTILITY_AS_CONST_H
11 
12 #include <__config>
13 #include <__utility/forward.h>
14 #include <__utility/move.h>
15 #include <type_traits>
16 
17 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18 #pragma GCC system_header
19 #endif
20 
21 _LIBCPP_PUSH_MACROS
22 #include <__undef_macros>
23 
24 _LIBCPP_BEGIN_NAMESPACE_STD
25 
26 #if _LIBCPP_STD_VER > 14
27 template <class _Tp>
28 _LIBCPP_NODISCARD_EXT constexpr add_const_t<_Tp>& as_const(_Tp& __t) noexcept { return __t; }
29 
30 template <class _Tp>
31 void as_const(const _Tp&&) = delete;
32 #endif
33 
34 _LIBCPP_END_NAMESPACE_STD
35 
36 _LIBCPP_POP_MACROS
37 
38 #endif // _LIBCPP___UTILITY_AS_CONST_H
39