xref: /freebsd/contrib/llvm-project/libcxx/include/__memory/voidify.h (revision 5f757f3ff9144b609b3c433dfd370cc6bdc191ad)
10eae32dcSDimitry Andric // -*- C++ -*-
20eae32dcSDimitry Andric //===----------------------------------------------------------------------===//
30eae32dcSDimitry Andric //
40eae32dcSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
50eae32dcSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
60eae32dcSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
70eae32dcSDimitry Andric //
80eae32dcSDimitry Andric //===----------------------------------------------------------------------===//
90eae32dcSDimitry Andric 
100eae32dcSDimitry Andric #ifndef _LIBCPP___MEMORY_VOIDIFY_H
110eae32dcSDimitry Andric #define _LIBCPP___MEMORY_VOIDIFY_H
120eae32dcSDimitry Andric 
130eae32dcSDimitry Andric #include <__config>
140eae32dcSDimitry Andric #include <__memory/addressof.h>
150eae32dcSDimitry Andric 
160eae32dcSDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
170eae32dcSDimitry Andric #  pragma GCC system_header
180eae32dcSDimitry Andric #endif
190eae32dcSDimitry Andric 
200eae32dcSDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
210eae32dcSDimitry Andric 
220eae32dcSDimitry Andric template <typename _Tp>
23bdd1243dSDimitry Andric _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void* __voidify(_Tp& __from) {
240eae32dcSDimitry Andric   // Cast away cv-qualifiers to allow modifying elements of a range through const iterators.
25*5f757f3fSDimitry Andric   return const_cast<void*>(static_cast<const volatile void*>(std::addressof(__from)));
260eae32dcSDimitry Andric }
270eae32dcSDimitry Andric 
280eae32dcSDimitry Andric _LIBCPP_END_NAMESPACE_STD
290eae32dcSDimitry Andric 
300eae32dcSDimitry Andric #endif // _LIBCPP___MEMORY_VOIDIFY_H
31