Index: adapted/adt/detail/extension.hpp =================================================================== --- adapted/adt/detail/extension.hpp (revision 78486) +++ adapted/adt/detail/extension.hpp (working copy) @@ -12,13 +12,28 @@ #include #include +#include +#include -namespace boost { namespace fusion { namespace detail -{ - template - struct get_identity - : remove_const::type> - {}; -}}} +namespace boost { namespace fusion +{ + namespace detail + { + template + struct get_identity + : remove_const::type> + {}; + } + + namespace extension + { + // Overload as_readonly() to unwrap adt_attribute_proxy. + template + typename adt_attribute_proxy::type as_readonly(const adt_attribute_proxy& proxy) + { + return proxy.get(); + } + } +}} #endif Index: support.hpp =================================================================== --- support.hpp (revision 78486) +++ support.hpp (working copy) @@ -19,5 +19,6 @@ #include #include #include +#include #endif Index: sequence/comparison/detail/equal_to.hpp =================================================================== --- sequence/comparison/detail/equal_to.hpp (revision 78486) +++ sequence/comparison/detail/equal_to.hpp (working copy) @@ -12,6 +12,7 @@ #include #include #include +#include namespace boost { namespace fusion { namespace detail { @@ -32,7 +33,7 @@ static bool call(I1 const& a, I2 const& b, mpl::false_) { - return *a == *b + return extension::as_readonly(*a) == extension::as_readonly(*b) && call(fusion::next(a), fusion::next(b)); } Index: sequence/comparison/detail/greater.hpp =================================================================== --- sequence/comparison/detail/greater.hpp (revision 78486) +++ sequence/comparison/detail/greater.hpp (working copy) @@ -12,6 +12,7 @@ #include #include #include +#include namespace boost { namespace fusion { namespace detail { @@ -32,8 +33,9 @@ static bool call(I1 const& a, I2 const& b, mpl::false_) { - return *a > *b || - (!(*b > *a) && call(fusion::next(a), fusion::next(b))); + return extension::as_readonly(*a) > extension::as_readonly(*b) || + (!(extension::as_readonly(*b) > extension::as_readonly(*a)) && + call(fusion::next(a), fusion::next(b))); } template Index: sequence/comparison/detail/not_equal_to.hpp =================================================================== --- sequence/comparison/detail/not_equal_to.hpp (revision 78486) +++ sequence/comparison/detail/not_equal_to.hpp (working copy) @@ -12,6 +12,7 @@ #include #include #include +#include namespace boost { namespace fusion { namespace detail { @@ -32,7 +33,7 @@ static bool call(I1 const& a, I2 const& b, mpl::false_) { - return *a != *b + return extension::as_readonly(*a) != extension::as_readonly(*b) || call(fusion::next(a), fusion::next(b)); } Index: sequence/comparison/detail/less_equal.hpp =================================================================== --- sequence/comparison/detail/less_equal.hpp (revision 78486) +++ sequence/comparison/detail/less_equal.hpp (working copy) @@ -12,6 +12,7 @@ #include #include #include +#include namespace boost { namespace fusion { namespace detail { @@ -32,8 +33,9 @@ static bool call(I1 const& a, I2 const& b, mpl::false_) { - return *a <= *b - && (!(*b <= *a) || call(fusion::next(a), fusion::next(b))); + return extension::as_readonly(*a) <= extension::as_readonly(*b) + && (!(extension::as_readonly(*b) <= extension::as_readonly(*a)) || + call(fusion::next(a), fusion::next(b))); } template Index: sequence/comparison/detail/greater_equal.hpp =================================================================== --- sequence/comparison/detail/greater_equal.hpp (revision 78486) +++ sequence/comparison/detail/greater_equal.hpp (working copy) @@ -12,6 +12,7 @@ #include #include #include +#include namespace boost { namespace fusion { namespace detail { @@ -32,8 +33,9 @@ static bool call(I1 const& a, I2 const& b, mpl::false_) { - return *a >= *b - && (!(*b >= *a) || call(fusion::next(a), fusion::next(b))); + return extension::as_readonly(*a) >= extension::as_readonly(*b) + && (!(extension::as_readonly(*b) >= extension::as_readonly(*a)) || + call(fusion::next(a), fusion::next(b))); } template Index: sequence/comparison/detail/less.hpp =================================================================== --- sequence/comparison/detail/less.hpp (revision 78486) +++ sequence/comparison/detail/less.hpp (working copy) @@ -12,6 +12,7 @@ #include #include #include +#include namespace boost { namespace fusion { namespace detail { @@ -32,8 +33,9 @@ static bool call(I1 const& a, I2 const& b, mpl::false_) { - return *a < *b || - (!(*b < *a) && call(fusion::next(a), fusion::next(b))); + return extension::as_readonly(*a) < extension::as_readonly(*b) || + (!(extension::as_readonly(*b) < extension::as_readonly(*a)) && + call(fusion::next(a), fusion::next(b))); } template Index: support/as_readonly.hpp =================================================================== --- support/as_readonly.hpp (revision 0) +++ support/as_readonly.hpp (revision 0) @@ -0,0 +1,27 @@ +/*============================================================================= + Copyright (c) 2012 Nathan Ridge + + 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) +==============================================================================*/ +#ifndef BOOST_FUSION_SUPPORT_AS_READONLY_HPP +#define BOOST_FUSION_SUPPORT_AS_READONLY_HPP + +namespace boost { namespace fusion { namespace extension +{ + + // A customization point that allows certain wrappers around + // Fusion sequence elements (e.g. adt_attribute_proxy) to be + // unwrapped in contexts where the element only needs to be + // read. The library wraps accesses to Fusion elements in + // such contexts with calls to this function. Users can + // specialize this function for their own wrappers. + template + const T& as_readonly(const T& obj) + { + return obj; + } + +}}} + +#endif