2 // (C) Copyright John Maddock 2000.
3 // Use, modification and distribution are subject to the Boost Software License,
4 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt).
7 // See http://www.boost.org/libs/type_traits for most recent version including documentation.
9 #ifndef BOOST_TT_ALIGNMENT_OF_HPP_INCLUDED
10 #define BOOST_TT_ALIGNMENT_OF_HPP_INCLUDED
12 #include "boost/config.hpp"
15 // should be the last #include
16 #include "boost/type_traits/detail/size_t_trait_def.hpp"
19 # pragma warning(push)
20 # pragma warning(disable: 4121) // alignment is sensitive to packing
22 #if defined(__BORLANDC__) && (__BORLANDC__ < 0x600)
23 #pragma option push -Vx- -Ve-
28 template <typename T> struct alignment_of;
30 // get the alignment of some arbitrary type:
34 struct alignment_of_hack
42 template <unsigned A, unsigned S>
43 struct alignment_logic
45 BOOST_STATIC_CONSTANT(std::size_t, value = A < S ? A : S);
49 template< typename T >
50 struct alignment_of_impl
52 BOOST_STATIC_CONSTANT(std::size_t, value =
53 (::boost::detail::alignment_logic<
54 sizeof(detail::alignment_of_hack<T>) - sizeof(T),
61 BOOST_TT_AUX_SIZE_T_TRAIT_DEF1(alignment_of,T,::boost::detail::alignment_of_impl<T>::value)
63 // references have to be treated specially, assume
64 // that a reference is just a special pointer:
65 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
67 struct alignment_of<T&>
73 // long double gives an incorrect value of 10 (!)
74 // unless we do this...
75 struct long_double_wrapper{ long double ld; };
76 template<> struct alignment_of<long double>
77 : public alignment_of<long_double_wrapper>{};
80 // void has to be treated specially:
81 BOOST_TT_AUX_SIZE_T_TRAIT_SPEC1(alignment_of,void,0)
82 #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
83 BOOST_TT_AUX_SIZE_T_TRAIT_SPEC1(alignment_of,void const,0)
84 BOOST_TT_AUX_SIZE_T_TRAIT_SPEC1(alignment_of,void volatile,0)
85 BOOST_TT_AUX_SIZE_T_TRAIT_SPEC1(alignment_of,void const volatile,0)
90 #if defined(__BORLANDC__) && (__BORLANDC__ < 0x600)
97 #include "boost/type_traits/detail/size_t_trait_undef.hpp"
99 #endif // BOOST_TT_ALIGNMENT_OF_HPP_INCLUDED