From 55e37c0fa0ae698e8faaf39d2dcc83e9ca7979f4 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 10 Apr 2002 03:50:08 +0000 Subject: [PATCH] alignment_traits.hpp: - Slight modification to Fernando Cacciola's fix to type_with_alignment, for the Borland C++ compiler. [SVN r13417] --- .../boost/type_traits/alignment_traits.hpp | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/include/boost/type_traits/alignment_traits.hpp b/include/boost/type_traits/alignment_traits.hpp index ad16b47..49f09f8 100644 --- a/include/boost/type_traits/alignment_traits.hpp +++ b/include/boost/type_traits/alignment_traits.hpp @@ -42,6 +42,7 @@ struct alignment_of_hack alignment_of_hack(); }; + template struct alignment_logic { @@ -98,11 +99,11 @@ typedef int (alignment_dummy::*member_function_ptr)(); * The ct_if implementation is temporary code. It will be replaced with MPL * in the future... */ -struct select_then -{ +struct select_then +{ template struct result - { + { typedef Then type; }; }; @@ -165,6 +166,13 @@ union max_align #undef BOOST_TT_CHOOSE_LOWER_ALIGNMENT #undef BOOST_TT_CHOOSE_T +template +struct is_aligned +{ + BOOST_STATIC_CONSTANT(bool, + value = (TAlign >= Align) & (TAlign % Align == 0)); +}; + } // This alignment method originally due to Brian Parker, implemented by David @@ -174,12 +182,10 @@ class type_with_alignment { typedef detail::lower_alignment t1; - BOOST_STATIC_CONSTANT(bool, t1_aligned = - (alignment_of::value >= Align) - & (alignment_of::value % Align == 0)); - + typedef type_with_alignment this_type; + typedef typename detail::ct_if< - t1_aligned + detail::is_aligned::value, Align>::value , t1 , detail::max_align >::type align_t;