From 6a01312869d6b2c6e7bf987308cb6f7d9aa56d34 Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Mon, 2 Apr 2007 13:20:16 +0000 Subject: [PATCH] workaround for VC7.1 getting confused with optional and variant boost::get functions [SVN r37337] --- .../adapted/variant/variant_iterator.hpp | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/include/boost/fusion/sequence/adapted/variant/variant_iterator.hpp b/include/boost/fusion/sequence/adapted/variant/variant_iterator.hpp index 0bdcf311..9372002c 100644 --- a/include/boost/fusion/sequence/adapted/variant/variant_iterator.hpp +++ b/include/boost/fusion/sequence/adapted/variant/variant_iterator.hpp @@ -2,7 +2,7 @@ Copyright (c) 2001-2006 Joel de Guzman Copyright (c) 2005-2006 Dan Marsden - Distributed under the Boost Software License, Version 1.0. (See accompanying + Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #if !defined(BOOST_FUSION_VARIANT_ITERATOR_12112006_1617) @@ -19,8 +19,9 @@ #include #include #include +#include -namespace boost { namespace fusion +namespace boost { namespace fusion { struct forward_traversal_tag; @@ -39,7 +40,7 @@ namespace boost { namespace fusion struct next { typedef variant_iterator< - typename Iterator::variant_type, + typename Iterator::variant_type, typename mpl::next::type> type; static type @@ -73,18 +74,32 @@ namespace boost { namespace fusion template struct deref { - typedef typename + typedef typename mpl::eval_if< is_const , add_const::type> , mpl::deref - >::type + >::type value_type; - typedef typename + typedef typename add_reference::type type; +#if BOOST_WORKAROUND(BOOST_MSVC, < 1400) +// for some unknown reason (compiler bug) VC7.1 gets confused with +// variant and optional get functions. + static type + call(Iterator const & it) + { + boost::detail::variant::get_visitor v; + typedef typename mpl::deref::type type; + if (type* result = it.var_.apply_visitor(v)) + return *result; + it.var_ = type(); // prime the variant + return *it.var_.apply_visitor(v); // no-throw! + } +#else static type call(Iterator const & it) { @@ -94,6 +109,7 @@ namespace boost { namespace fusion it.var_ = type(); // prime the variant return *boost::get(&it.var_); // no-throw! } +#endif }; }; }}