Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:23

0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009 
0010 #ifndef _LIBCPP___CXX03___BIT_BIT_CAST_H
0011 #define _LIBCPP___CXX03___BIT_BIT_CAST_H
0012 
0013 #include <__cxx03/__config>
0014 #include <__cxx03/__type_traits/is_trivially_copyable.h>
0015 
0016 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0017 #  pragma GCC system_header
0018 #endif
0019 
0020 _LIBCPP_BEGIN_NAMESPACE_STD
0021 
0022 #ifndef _LIBCPP_CXX03_LANG
0023 
0024 template <class _ToType, class _FromType>
0025 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI constexpr _ToType __bit_cast(const _FromType& __from) noexcept {
0026   return __builtin_bit_cast(_ToType, __from);
0027 }
0028 
0029 #endif // _LIBCPP_CXX03_LANG
0030 
0031 #if _LIBCPP_STD_VER >= 20
0032 
0033 template <class _ToType, class _FromType>
0034   requires(sizeof(_ToType) == sizeof(_FromType) && is_trivially_copyable_v<_ToType> &&
0035            is_trivially_copyable_v<_FromType>)
0036 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _ToType bit_cast(const _FromType& __from) noexcept {
0037   return __builtin_bit_cast(_ToType, __from);
0038 }
0039 
0040 #endif // _LIBCPP_STD_VER >= 20
0041 
0042 _LIBCPP_END_NAMESPACE_STD
0043 
0044 #endif // _LIBCPP___CXX03___BIT_BIT_CAST_H