From 295ae05e407ccaa36d6a34d0fe5adba74835a4ad Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 3 Dec 2004 09:55:30 +0000 Subject: [PATCH] Fix the problems described in this thread: http://lists.boost.org/MailArchives/boost-users/msg08656.php [SVN r26410] --- include/boost/iterator/detail/config_def.hpp | 6 +++++- test/Jamfile | 2 ++ test/constant_iterator_arrow.cpp | 16 ++++++++++++++++ test/constant_iterator_arrow_fail.cpp | 20 ++++++++++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100755 test/constant_iterator_arrow.cpp create mode 100755 test/constant_iterator_arrow_fail.cpp diff --git a/include/boost/iterator/detail/config_def.hpp b/include/boost/iterator/detail/config_def.hpp index fcdb9d6..1c71606 100644 --- a/include/boost/iterator/detail/config_def.hpp +++ b/include/boost/iterator/detail/config_def.hpp @@ -22,7 +22,11 @@ # define BOOST_ITERATOR_CONFIG_DEF #endif -#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ +// We enable this always now. Otherwise, the simple case in +// libs/iterator/test/constant_iterator_arrow.cpp fails to compile +// because the operator-> return is improperly deduced as a non-const +// pointer. +#if 1 || defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x531)) // Recall that in general, compilers without partial specialization diff --git a/test/Jamfile b/test/Jamfile index b206bde..069462e 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -38,6 +38,8 @@ test-suite iterator [ compile iterator_archetype_cc.cpp ] [ compile-fail iter_archetype_default_ctor.cpp ] [ compile-fail lvalue_concept_fail.cpp ] + [ compile constant_iterator_arrow.cpp ] + [ compile-fail constant_iterator_arrow_fail.cpp ] [ run transform_iterator_test.cpp ] [ run indirect_iterator_test.cpp ] [ compile indirect_iter_member_types.cpp ] diff --git a/test/constant_iterator_arrow.cpp b/test/constant_iterator_arrow.cpp new file mode 100755 index 0000000..3579c53 --- /dev/null +++ b/test/constant_iterator_arrow.cpp @@ -0,0 +1,16 @@ +// Copyright David Abrahams 2004. 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) + +#include +#include + +struct my_iter : boost::iterator_adaptor const*> +{ + my_iter(std::pair const*); + my_iter(); +}; + +std::pair const x(1,1); +my_iter p(&x); +int y = p->first; // operator-> attempts to return an non-const pointer diff --git a/test/constant_iterator_arrow_fail.cpp b/test/constant_iterator_arrow_fail.cpp new file mode 100755 index 0000000..05f551a --- /dev/null +++ b/test/constant_iterator_arrow_fail.cpp @@ -0,0 +1,20 @@ +// Copyright David Abrahams 2004. 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) + +#include +#include + +struct my_iter : boost::iterator_adaptor const*> +{ + my_iter(std::pair const*); + my_iter(); +}; + +std::pair const x(1,1); +my_iter p(&x); + +void test() +{ + p->first = 3; +}