max_align.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef BOOST_CORE_MAX_ALIGN_HPP_INCLUDED
  2. #define BOOST_CORE_MAX_ALIGN_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/core/alignof.hpp>
  11. #include <boost/config.hpp>
  12. #include <cstddef>
  13. // BOOST_CORE_HAS_FLOAT128
  14. #if defined(BOOST_HAS_FLOAT128)
  15. # define BOOST_CORE_HAS_FLOAT128
  16. #elif defined(__SIZEOF_FLOAT128__)
  17. # define BOOST_CORE_HAS_FLOAT128
  18. #elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 404) && defined(__i386__)
  19. # define BOOST_CORE_HAS_FLOAT128
  20. #endif
  21. // max_align_t, max_align
  22. namespace boost
  23. {
  24. namespace core
  25. {
  26. union max_align_t
  27. {
  28. char c;
  29. short s;
  30. int i;
  31. long l;
  32. #if !defined(BOOST_NO_LONG_LONG)
  33. boost::long_long_type ll;
  34. #endif
  35. #if defined(BOOST_HAS_INT128)
  36. boost::int128_type i128;
  37. #endif
  38. float f;
  39. double d;
  40. long double ld;
  41. #if defined(BOOST_CORE_HAS_FLOAT128)
  42. __float128 f128;
  43. #endif
  44. void* p;
  45. void (*pf) ();
  46. int max_align_t::* pm;
  47. void (max_align_t::*pmf)();
  48. };
  49. BOOST_CONSTEXPR_OR_CONST std::size_t max_align = BOOST_CORE_ALIGNOF( max_align_t );
  50. } // namespace core
  51. } // namespace boost
  52. #endif // #ifndef BOOST_CORE_MAX_ALIGN_HPP_INCLUDED