diff --git a/include/boost/type_traits/type_with_alignment.hpp b/include/boost/type_traits/type_with_alignment.hpp index f61aa19..d1b7a03 100644 --- a/include/boost/type_traits/type_with_alignment.hpp +++ b/include/boost/type_traits/type_with_alignment.hpp @@ -1,4 +1,3 @@ - // (C) Copyright John Maddock 2000. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -57,12 +56,64 @@ typedef int (alignment_dummy::*member_function_ptr)(); BOOST_PP_LIST_APPEND(BOOST_TT_ALIGNMENT_BASE_TYPES, \ BOOST_TT_ALIGNMENT_STRUCT_TYPES) -#define BOOST_TT_CHOOSE_MIN_ALIGNMENT(R,P,I,T) \ - typename mpl::if_c< \ - (alignment_of< T >::value == target && !BOOST_PP_CAT(found,I)), \ - T, char>::type BOOST_PP_CAT(t,I); \ - enum { BOOST_PP_CAT(found,BOOST_PP_INC(I)) = \ - alignment_of< T >::value == target || BOOST_PP_CAT(found,I) } ; +// +// lower_alignment_helper -- +// +// This template gets instantiated a lot, so use partial +// specialization when available to reduce the compiler burden. +// +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +template +struct lower_alignment_helper_impl +{ + template + struct apply + { + typedef char type; + enum { value = true }; + }; +}; + +template <> +struct lower_alignment_helper_impl +{ + template + struct apply + : mpl::if_c<(alignment_of::value == target), TestType, char> + { + enum { value = (alignment_of::value == target) }; + }; +}; + +template +struct lower_alignment_helper + : lower_alignment_helper_impl::template apply +{ +}; +#else +template +struct lower_alignment_helper +{ + typedef char type; + enum { value = true }; +}; + +template +struct lower_alignment_helper + : mpl::if_c<(alignment_of::value == target), TestType, char> +{ + enum { value = (alignment_of::value == target) }; +}; +#endif + +#define BOOST_TT_CHOOSE_MIN_ALIGNMENT(R,P,I,T) \ + typename lower_alignment_helper< \ + BOOST_PP_CAT(found,I),target,T \ + >::type BOOST_PP_CAT(t,I); \ + enum { \ + BOOST_PP_CAT(found,BOOST_PP_INC(I)) \ + = lower_alignment_helper::value \ + }; #define BOOST_TT_CHOOSE_T(R,P,I,T) T BOOST_PP_CAT(t,I);