| 1 | #ifndef BOOST_CORE_ALIGNOF_HPP_INCLUDED |
| 2 | #define BOOST_CORE_ALIGNOF_HPP_INCLUDED |
| 3 | |
| 4 | // MS compatible compilers support #pragma once |
| 5 | |
| 6 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) |
| 7 | # pragma once |
| 8 | #endif |
| 9 | |
| 10 | // Copyright 2023 Peter Dimov |
| 11 | // Distributed under the Boost Software License, Version 1.0. |
| 12 | // https://www.boost.org/LICENSE_1_0.txt |
| 13 | |
| 14 | #include <boost/config.hpp> |
| 15 | #include <cstddef> |
| 16 | |
| 17 | #if !defined(BOOST_NO_CXX11_ALIGNOF) |
| 18 | |
| 19 | #define BOOST_CORE_ALIGNOF alignof |
| 20 | |
| 21 | #elif defined(__GNUC__) |
| 22 | |
| 23 | #define BOOST_CORE_ALIGNOF __alignof__ |
| 24 | |
| 25 | #elif defined(_MSC_VER) |
| 26 | |
| 27 | #define BOOST_CORE_ALIGNOF __alignof |
| 28 | |
| 29 | #else |
| 30 | |
| 31 | namespace boost |
| 32 | { |
| 33 | namespace core |
| 34 | { |
| 35 | namespace detail |
| 36 | { |
| 37 | |
| 38 | template<class T> struct alignof_helper |
| 39 | { |
| 40 | char x; |
| 41 | T t; |
| 42 | }; |
| 43 | |
| 44 | } // namespace detail |
| 45 | } // namespace core |
| 46 | } // namespace boost |
| 47 | |
| 48 | #if defined(__GNUC__) |
| 49 | // ignoring -Wvariadic-macros with #pragma doesn't work under GCC |
| 50 | # pragma GCC system_header |
| 51 | #endif |
| 52 | |
| 53 | #define BOOST_CORE_ALIGNOF(...) offsetof( ::boost::core::detail::alignof_helper<__VA_ARGS__>, t ); |
| 54 | |
| 55 | #endif |
| 56 | |
| 57 | #endif // #ifndef BOOST_CORE_ALIGNOF_HPP_INCLUDED |
| 58 | |