Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:52:31

0001 // Copyright 2014 Renato Tegon Forti, Antony Polukhin.
0002 // Copyright Antony Polukhin, 2015-2023.
0003 //
0004 // Distributed under the Boost Software License, Version 1.0.
0005 // (See accompanying file LICENSE_1_0.txt
0006 // or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 
0008 #ifndef BOOST_STACKTRACE_DETAIL_VOID_PTR_CAST_HPP
0009 #define BOOST_STACKTRACE_DETAIL_VOID_PTR_CAST_HPP
0010 
0011 #include <boost/config.hpp>
0012 #ifdef BOOST_HAS_PRAGMA_ONCE
0013 #   pragma once
0014 #endif
0015 
0016 #include <type_traits>
0017 
0018 #if defined(__GNUC__) && defined(__GNUC_MINOR__) && (__GNUC__ * 100 + __GNUC_MINOR__ > 301)
0019 #   pragma GCC system_header
0020 #endif
0021 
0022 namespace boost { namespace stacktrace { namespace detail {
0023 
0024 // GCC warns when reinterpret_cast between function pointer and object pointer occur.
0025 // This functionsuppress the warnings and ensures that such casts are safe.
0026 template <class To, class From>
0027 To void_ptr_cast(From* v) noexcept {
0028     static_assert(
0029         std::is_pointer<To>::value,
0030         "`void_ptr_cast` function must be used only for casting to or from void pointers."
0031     );
0032 
0033     static_assert(
0034         sizeof(From*) == sizeof(To),
0035         "Pointer to function and pointer to object differ in size on your platform."
0036     );
0037 
0038     return reinterpret_cast<To>(v);
0039 }
0040 
0041 
0042 }}} // boost::stacktrace::detail
0043 
0044 #endif // BOOST_STACKTRACE_DETAIL_VOID_PTR_CAST_HPP
0045