2 // (C) Copyright John Maddock 2000.
3 // Permission to copy, use, modify, sell and
4 // distribute this software is granted provided this copyright notice appears
5 // in all copies. This software is provided "as is" without express or implied
6 // warranty, and with no claim as to its suitability for any purpose.
9 // defines alignment_of:
11 #ifndef ALIGNMENT_TYPE_TRAITS_HPP
12 #define ALIGNMENT_TYPE_TRAITS_HPP
16 #ifndef BOOST_ICE_TYPE_TRAITS_HPP
17 #include <boost/type_traits/ice.hpp>
22 // get the alignment of some arbitrary type:
26 struct alignment_of_hack
33 template <unsigned A, unsigned S>
34 struct alignment_logic
36 BOOST_STATIC_CONSTANT(std::size_t, value = A < S ? A : S);
44 BOOST_STATIC_CONSTANT(std::size_t, value =
45 (::boost::detail::alignment_logic<
46 sizeof(detail::alignment_of_hack<T>) - sizeof(T),
52 // references have to be treated specially, assume
53 // that a reference is just a special pointer:
54 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
56 struct alignment_of<T&>
59 BOOST_STATIC_CONSTANT(std::size_t, value = alignment_of<T*>::value);
63 // void has to be treated specially:
65 struct alignment_of<void>
66 { BOOST_STATIC_CONSTANT(std::size_t, value = 0); };
67 #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
69 struct alignment_of<const void>
70 { BOOST_STATIC_CONSTANT(std::size_t, value = 0); };
72 struct alignment_of<volatile void>
73 { BOOST_STATIC_CONSTANT(std::size_t, value = 0); };
75 struct alignment_of<const volatile void>
76 { BOOST_STATIC_CONSTANT(std::size_t, value = 0); };
81 #endif // ALIGNMENT_TYPE_TRAITS_HPP