|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r62754 - trunk/boost/variant
From: steven_at_[hidden]
Date: 2010-06-10 14:45:15
Author: steven_watanabe
Date: 2010-06-10 14:45:14 EDT (Thu, 10 Jun 2010)
New Revision: 62754
URL: http://svn.boost.org/trac/boost/changeset/62754
Log:
Use the least common multiple of alignments instead of the max. Fixes #993
Text files modified:
trunk/boost/variant/variant.hpp | 29 +++++++++++++++++++++++------
1 files changed, 23 insertions(+), 6 deletions(-)
Modified: trunk/boost/variant/variant.hpp
==============================================================================
--- trunk/boost/variant/variant.hpp (original)
+++ trunk/boost/variant/variant.hpp 2010-06-10 14:45:14 EDT (Thu, 10 Jun 2010)
@@ -40,6 +40,7 @@
#include "boost/detail/reference_content.hpp"
#include "boost/aligned_storage.hpp"
#include "boost/blank.hpp"
+#include "boost/math/common_factor_ct.hpp"
#include "boost/static_assert.hpp"
#include "boost/preprocessor/cat.hpp"
#include "boost/preprocessor/repeat.hpp"
@@ -53,12 +54,14 @@
#include "boost/variant/recursive_wrapper_fwd.hpp"
#include "boost/variant/static_visitor.hpp"
-#include "boost/mpl/eval_if.hpp"
+#include "boost/mpl/assert.hpp"
#include "boost/mpl/begin_end.hpp"
#include "boost/mpl/bool.hpp"
-#include "boost/mpl/not.hpp"
+#include "boost/mpl/deref.hpp"
#include "boost/mpl/empty.hpp"
+#include "boost/mpl/eval_if.hpp"
#include "boost/mpl/find_if.hpp"
+#include "boost/mpl/fold.hpp"
#include "boost/mpl/front.hpp"
#include "boost/mpl/identity.hpp"
#include "boost/mpl/if.hpp"
@@ -69,7 +72,7 @@
#include "boost/mpl/logical.hpp"
#include "boost/mpl/max_element.hpp"
#include "boost/mpl/next.hpp"
-#include "boost/mpl/deref.hpp"
+#include "boost/mpl/not.hpp"
#include "boost/mpl/pair.hpp"
#include "boost/mpl/protect.hpp"
#include "boost/mpl/push_front.hpp"
@@ -77,7 +80,6 @@
#include "boost/mpl/size_t.hpp"
#include "boost/mpl/sizeof.hpp"
#include "boost/mpl/transform.hpp"
-#include "boost/mpl/assert.hpp"
///////////////////////////////////////////////////////////////////////////////
// Implementation Macros:
@@ -130,6 +132,19 @@
};
+struct add_alignment
+{
+ template <typename State, typename Item>
+ struct apply
+ : mpl::size_t<
+ ::boost::math::static_lcm<
+ BOOST_MPL_AUX_VALUE_WKND(State)::value
+ , ::boost::alignment_of<Item>::value
+ >::value
+ >
+ {};
+};
+
///////////////////////////////////////////////////////////////////////////////
// (detail) metafunction find_fallback_type
//
@@ -234,8 +249,10 @@
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0551))
- typedef typename max_value<
- types, alignment_of<mpl::_1>
+ typedef typename mpl::fold<
+ types
+ , mpl::size_t<1>
+ , add_alignment
>::type max_alignment;
#else // borland
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk