2 // (C) Copyright John Maddock 2000.
3 // Permission to copy, use, modify, sell and distribute this software is
4 // granted provided this copyright notice appears in all copies. This software
5 // is provided "as is" without express or implied warranty, and with no claim
6 // as to its suitability for any purpose.
8 #ifndef BOOST_TT_ALIGNMENT_OF_HPP_INCLUDED
9 #define BOOST_TT_ALIGNMENT_OF_HPP_INCLUDED
11 #include "boost/config.hpp"
14 // should be the last #include
15 #include "boost/type_traits/detail/size_t_trait_def.hpp"
18 # pragma warning(push)
19 # pragma warning(disable: 4121) // alignment is sensitive to packing
24 template <typename T> struct alignment_of;
26 // get the alignment of some arbitrary type:
30 struct alignment_of_hack
38 template <unsigned A, unsigned S>
39 struct alignment_logic
41 BOOST_STATIC_CONSTANT(std::size_t, value = A < S ? A : S);
45 template< typename T >
46 struct alignment_of_impl
48 BOOST_STATIC_CONSTANT(std::size_t, value =
49 (::boost::detail::alignment_logic<
50 sizeof(detail::alignment_of_hack<T>) - sizeof(T),
57 BOOST_TT_AUX_SIZE_T_TRAIT_DEF1(alignment_of,T,::boost::detail::alignment_of_impl<T>::value)
59 // references have to be treated specially, assume
60 // that a reference is just a special pointer:
61 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
63 struct alignment_of<T&>
69 // void has to be treated specially:
70 BOOST_TT_AUX_SIZE_T_TRAIT_SPEC1(alignment_of,void,0)
71 #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
72 BOOST_TT_AUX_SIZE_T_TRAIT_SPEC1(alignment_of,void const,0)
73 BOOST_TT_AUX_SIZE_T_TRAIT_SPEC1(alignment_of,void volatile,0)
74 BOOST_TT_AUX_SIZE_T_TRAIT_SPEC1(alignment_of,void const volatile,0)
83 #include "boost/type_traits/detail/size_t_trait_undef.hpp"
85 #endif // BOOST_TT_ALIGNMENT_OF_HPP_INCLUDED