github.com/searKing/golang/go@v1.2.117/os/signal/cgo/include/boost/stacktrace/detail/void_ptr_cast.hpp (about) 1 // Copyright 2014 Renato Tegon Forti, Antony Polukhin. 2 // Copyright Antony Polukhin, 2015-2023. 3 // 4 // Distributed under the Boost Software License, Version 1.0. 5 // (See accompanying file LICENSE_1_0.txt 6 // or copy at http://www.boost.org/LICENSE_1_0.txt) 7 8 #ifndef BOOST_STACKTRACE_DETAIL_VOID_PTR_CAST_HPP 9 #define BOOST_STACKTRACE_DETAIL_VOID_PTR_CAST_HPP 10 11 #include <boost/config.hpp> 12 #ifdef BOOST_HAS_PRAGMA_ONCE 13 # pragma once 14 #endif 15 16 #include <type_traits> 17 18 #if defined(__GNUC__) && defined(__GNUC_MINOR__) && (__GNUC__ * 100 + __GNUC_MINOR__ > 301) 19 # pragma GCC system_header 20 #endif 21 22 namespace boost { namespace stacktrace { namespace detail { 23 24 // GCC warns when reinterpret_cast between function pointer and object pointer occur. 25 // This functionsuppress the warnings and ensures that such casts are safe. 26 template <class To, class From> 27 To void_ptr_cast(From* v) noexcept { 28 static_assert( 29 std::is_pointer<To>::value, 30 "`void_ptr_cast` function must be used only for casting to or from void pointers." 31 ); 32 33 static_assert( 34 sizeof(From*) == sizeof(To), 35 "Pointer to function and pointer to object differ in size on your platform." 36 ); 37 38 return reinterpret_cast<To>(v); 39 } 40 41 42 }}} // boost::stacktrace::detail 43 44 #endif // BOOST_STACKTRACE_DETAIL_VOID_PTR_CAST_HPP 45