|
Boost-Commit : |
From: eric_at_[hidden]
Date: 2008-03-05 02:12:04
Author: eric_niebler
Date: 2008-03-05 02:12:03 EST (Wed, 05 Mar 2008)
New Revision: 43509
URL: http://svn.boost.org/trac/boost/changeset/43509
Log:
fix bug iterating over abstract base
Added:
trunk/libs/foreach/test/misc.cpp (contents, props changed)
Text files modified:
trunk/boost/foreach.hpp | 8 ++++----
trunk/libs/foreach/test/Jamfile.v2 | 1 +
2 files changed, 5 insertions(+), 4 deletions(-)
Modified: trunk/boost/foreach.hpp
==============================================================================
--- trunk/boost/foreach.hpp (original)
+++ trunk/boost/foreach.hpp 2008-03-05 02:12:03 EST (Wed, 05 Mar 2008)
@@ -347,8 +347,8 @@
//
// To treat the container as an array, use boost::as_array() in <boost/range/as_array.hpp>,
// as in BOOST_FOREACH( char ch, boost::as_array("hello") ) ...
- #if BOOST_MSVC > 1300
- BOOST_MPL_ASSERT_MSG( (!is_char_array<T>::value), IS_THIS_AN_ARRAY_OR_A_NULL_TERMINATED_STRING, (T) );
+ #if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
+ BOOST_MPL_ASSERT_MSG( (!is_char_array<T>::value), IS_THIS_AN_ARRAY_OR_A_NULL_TERMINATED_STRING, (T&) );
#endif
// If the type is a pointer to a null terminated string (as opposed
@@ -378,8 +378,8 @@
//
// To treat the container as an array, use boost::as_array() in <boost/range/as_array.hpp>,
// as in BOOST_FOREACH( char ch, boost::as_array("hello") ) ...
- #if BOOST_MSVC > 1300
- BOOST_MPL_ASSERT_MSG( (!is_char_array<T>::value), IS_THIS_AN_ARRAY_OR_A_NULL_TERMINATED_STRING, (T) );
+ #if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
+ BOOST_MPL_ASSERT_MSG( (!is_char_array<T>::value), IS_THIS_AN_ARRAY_OR_A_NULL_TERMINATED_STRING, (T&) );
#endif
// If the type is a pointer to a null terminated string (as opposed
Modified: trunk/libs/foreach/test/Jamfile.v2
==============================================================================
--- trunk/libs/foreach/test/Jamfile.v2 (original)
+++ trunk/libs/foreach/test/Jamfile.v2 2008-03-05 02:12:03 EST (Wed, 05 Mar 2008)
@@ -29,5 +29,6 @@
[ run rvalue_const_r.cpp ]
[ run rvalue_nonconst_r.cpp ]
[ run dependent_type.cpp ]
+ [ run misc.cpp ]
[ compile noncopyable.cpp ]
;
Added: trunk/libs/foreach/test/misc.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/foreach/test/misc.cpp 2008-03-05 02:12:03 EST (Wed, 05 Mar 2008)
@@ -0,0 +1,47 @@
+// misc.cpp
+//
+// (C) Copyright Eric Niebler 2008.
+// Use, modification and distribution are subject to 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)
+
+/*
+ Revision history:
+ 4 March 2008 : Initial version.
+*/
+
+#include <vector>
+#include <boost/test/minimal.hpp>
+#include <boost/foreach.hpp>
+
+struct xxx : std::vector<int>
+{
+ virtual ~xxx() = 0;
+};
+
+void test_abstract(xxx& rng)
+{
+ BOOST_FOREACH (int x, rng)
+ {
+ (void)x;
+ }
+}
+
+struct yyy : std::vector<int>
+{
+ void test()
+ {
+ BOOST_FOREACH(int x, *this)
+ {
+ (void)x;
+ }
+ }
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// test_main
+//
+int test_main( int, char*[] )
+{
+ return 0;
+}
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