align.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Official repository: https://github.com/boostorg/json
  8. //
  9. #ifndef BOOST_JSON_DETAIL_ALIGN_HPP
  10. #define BOOST_JSON_DETAIL_ALIGN_HPP
  11. #ifndef BOOST_JSON_STANDALONE
  12. #include <boost/align/align.hpp>
  13. #else
  14. #include <cstddef>
  15. #include <memory>
  16. #endif
  17. BOOST_JSON_NS_BEGIN
  18. namespace detail {
  19. #ifndef BOOST_JSON_STANDALONE
  20. using boost::alignment::align;
  21. // VFALCO workaround until Boost.Align has the type
  22. struct class_type {};
  23. enum unscoped_enumeration_type { };
  24. enum class scoped_enumeration_type { };
  25. // [support.types] p5: The type max_align_t is a trivial
  26. // standard-layout type whose alignment requirement
  27. // is at least as great as that of every scalar type.
  28. struct max_align_t
  29. {
  30. // arithmetic types
  31. char a;
  32. char16_t b;
  33. char32_t c;
  34. bool d;
  35. short int e;
  36. int f;
  37. long int g;
  38. long long int h;
  39. wchar_t i;
  40. float j;
  41. double k;
  42. long double l;
  43. // enumeration types
  44. unscoped_enumeration_type m;
  45. scoped_enumeration_type n;
  46. // pointer types
  47. void* o;
  48. char* p;
  49. class_type* q;
  50. unscoped_enumeration_type* r;
  51. scoped_enumeration_type* s;
  52. void(*t)();
  53. // pointer to member types
  54. char class_type::* u;
  55. void (class_type::*v)();
  56. // nullptr
  57. std::nullptr_t w;
  58. };
  59. #else
  60. using std::align;
  61. using max_align_t = std::max_align_t;
  62. #endif
  63. } // detail
  64. BOOST_JSON_NS_END
  65. #endif