File indexing completed on 2025-01-30 10:01:38
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_TT_ALIGNMENT_OF_HPP_INCLUDED
0010 #define BOOST_TT_ALIGNMENT_OF_HPP_INCLUDED
0011
0012 #include <boost/config.hpp>
0013 #include <cstddef>
0014
0015 #include <boost/type_traits/intrinsics.hpp>
0016 #include <boost/type_traits/integral_constant.hpp>
0017
0018 #ifdef BOOST_MSVC
0019 # pragma warning(push)
0020 # pragma warning(disable: 4121 4512)
0021 #endif
0022 #if defined(BOOST_BORLANDC) && (BOOST_BORLANDC < 0x600)
0023 #pragma option push -Vx- -Ve-
0024 #endif
0025
0026 namespace boost {
0027
0028 template <typename T> struct alignment_of;
0029
0030
0031 namespace detail {
0032
0033 #ifdef BOOST_MSVC
0034 #pragma warning(push)
0035 #pragma warning(disable:4324)
0036 #endif
0037 template <typename T>
0038 struct alignment_of_hack
0039 {
0040 char c;
0041 T t;
0042 alignment_of_hack();
0043 };
0044 #ifdef BOOST_MSVC
0045 #pragma warning(pop)
0046 #endif
0047
0048 template <unsigned A, unsigned S>
0049 struct alignment_logic
0050 {
0051 BOOST_STATIC_CONSTANT(std::size_t, value = A < S ? A : S);
0052 };
0053
0054
0055 template< typename T >
0056 struct alignment_of_impl
0057 {
0058 #if defined(BOOST_MSVC) && (BOOST_MSVC >= 1400)
0059
0060
0061
0062
0063
0064 BOOST_STATIC_CONSTANT(std::size_t, value =
0065 (::boost::detail::alignment_logic<
0066 sizeof(::boost::detail::alignment_of_hack<T>) - sizeof(T),
0067 __alignof(T)
0068 >::value));
0069 #elif !defined(BOOST_ALIGNMENT_OF)
0070 BOOST_STATIC_CONSTANT(std::size_t, value =
0071 (::boost::detail::alignment_logic<
0072 sizeof(::boost::detail::alignment_of_hack<T>) - sizeof(T),
0073 sizeof(T)
0074 >::value));
0075 #else
0076
0077
0078
0079
0080
0081
0082 BOOST_STATIC_CONSTANT(std::size_t, value = BOOST_ALIGNMENT_OF(T));
0083 #endif
0084 };
0085
0086 }
0087
0088 template <class T> struct alignment_of : public integral_constant<std::size_t, ::boost::detail::alignment_of_impl<T>::value>{};
0089
0090
0091
0092 template <typename T> struct alignment_of<T&> : public alignment_of<T*>{};
0093
0094 #ifdef BOOST_BORLANDC
0095
0096
0097 struct long_double_wrapper{ long double ld; };
0098 template<> struct alignment_of<long double> : public alignment_of<long_double_wrapper>{};
0099 #endif
0100
0101
0102 template<> struct alignment_of<void> : integral_constant<std::size_t, 0>{};
0103 #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
0104 template<> struct alignment_of<void const> : integral_constant<std::size_t, 0>{};
0105 template<> struct alignment_of<void const volatile> : integral_constant<std::size_t, 0>{};
0106 template<> struct alignment_of<void volatile> : integral_constant<std::size_t, 0>{};
0107 #endif
0108
0109 }
0110
0111 #if defined(BOOST_BORLANDC) && (BOOST_BORLANDC < 0x600)
0112 #pragma option pop
0113 #endif
0114 #ifdef BOOST_MSVC
0115 # pragma warning(pop)
0116 #endif
0117
0118 #endif
0119