alignof.hpp 1.0 KB

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