diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-10-19 08:57:20 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-10-19 08:57:20 +0200 |
commit | ed6115361006240e3c7b02295599e4534cc55a13 (patch) | |
tree | 612f12d6c7c49421102041fceb7609db8ab8257e /cutl/details/boost/iterator | |
parent | af8d1a0139ca105c6830f4ac7c320aca2e1c1f5e (diff) |
Update internal Boost subset to 1.54.0
Diffstat (limited to 'cutl/details/boost/iterator')
-rw-r--r-- | cutl/details/boost/iterator/iterator_facade.hpp | 68 |
1 files changed, 32 insertions, 36 deletions
diff --git a/cutl/details/boost/iterator/iterator_facade.hpp b/cutl/details/boost/iterator/iterator_facade.hpp index cb7b0dc..63858b5 100644 --- a/cutl/details/boost/iterator/iterator_facade.hpp +++ b/cutl/details/boost/iterator/iterator_facade.hpp @@ -14,8 +14,8 @@ #include <cutl/details/boost/iterator/detail/facade_iterator_category.hpp> #include <cutl/details/boost/iterator/detail/enable_if.hpp> -#include <cutl/details/boost/implicit_cast.hpp> #include <cutl/details/boost/static_assert.hpp> +#include <cutl/details/boost/utility/addressof.hpp> #include <cutl/details/boost/type_traits/is_same.hpp> #include <cutl/details/boost/type_traits/add_const.hpp> @@ -147,7 +147,7 @@ namespace cutl_details_boost // Returning a mutable reference allows nonsense like // (*r++).mutate(), but it imposes fewer assumptions about the - // behavior of the value_type. In particular, recall taht + // behavior of the value_type. In particular, recall that // (*r).mutate() is legal if operator* returns by value. value_type& operator*() const @@ -294,46 +294,43 @@ namespace cutl_details_boost // operator->() needs special support for input iterators to strictly meet the // standard's requirements. If *i is not a reference type, we must still - // produce a lvalue to which a pointer can be formed. We do that by - // returning an instantiation of this special proxy class template. - template <class T> - struct operator_arrow_proxy + // produce an lvalue to which a pointer can be formed. We do that by + // returning a proxy object containing an instance of the reference object. + template <class Reference, class Pointer> + struct operator_arrow_dispatch // proxy references { - operator_arrow_proxy(T const* px) : m_value(*px) {} - T* operator->() const { return &m_value; } - // This function is needed for MWCW and BCC, which won't call operator-> - // again automatically per 13.3.1.2 para 8 - operator T*() const { return &m_value; } - mutable T m_value; + struct proxy + { + explicit proxy(Reference const & x) : m_ref(x) {} + Reference* operator->() { return cutl_details_boost::addressof(m_ref); } + // This function is needed for MWCW and BCC, which won't call + // operator-> again automatically per 13.3.1.2 para 8 + operator Reference*() { return cutl_details_boost::addressof(m_ref); } + Reference m_ref; + }; + typedef proxy result_type; + static result_type apply(Reference const & x) + { + return result_type(x); + } }; - // A metafunction that gets the result type for operator->. Also - // has a static function make() which builds the result from a - // Reference - template <class ValueType, class Reference, class Pointer> - struct operator_arrow_result + template <class T, class Pointer> + struct operator_arrow_dispatch<T&, Pointer> // "real" references { - // CWPro8.3 won't accept "operator_arrow_result::type", and we - // need that type below, so metafunction forwarding would be a - // losing proposition here. - typedef typename mpl::if_< - is_reference<Reference> - , Pointer - , operator_arrow_proxy<ValueType> - >::type type; - - static type make(Reference x) + typedef Pointer result_type; + static result_type apply(T& x) { - return cutl_details_boost::implicit_cast<type>(&x); + return cutl_details_boost::addressof(x); } }; # if BOOST_WORKAROUND(BOOST_MSVC, < 1300) // Deal with ETI template<> - struct operator_arrow_result<int, int, int> + struct operator_arrow_dispatch<int, int> { - typedef int type; + typedef int result_type; }; # endif @@ -618,11 +615,10 @@ namespace cutl_details_boost Value, CategoryOrTraversal, Reference, Difference > associated_types; - typedef cutl_details_boost::detail::operator_arrow_result< - typename associated_types::value_type - , Reference + typedef cutl_details_boost::detail::operator_arrow_dispatch< + Reference , typename associated_types::pointer - > pointer_; + > operator_arrow_dispatch_; protected: // For use by derived classes @@ -634,7 +630,7 @@ namespace cutl_details_boost typedef Reference reference; typedef Difference difference_type; - typedef typename pointer_::type pointer; + typedef typename operator_arrow_dispatch_::result_type pointer; typedef typename associated_types::iterator_category iterator_category; @@ -645,7 +641,7 @@ namespace cutl_details_boost pointer operator->() const { - return pointer_::make(*this->derived()); + return operator_arrow_dispatch_::apply(*this->derived()); } typename cutl_details_boost::detail::operator_brackets_result<Derived,Value,reference>::type |