From 12652dac2bf447e7efeec8996b0dad591d5bf22a Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Tue, 2 May 2006 14:37:54 +0000 Subject: [PATCH] make foreach work with collection types that are abstract [SVN r33906] --- include/boost/foreach.hpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/include/boost/foreach.hpp b/include/boost/foreach.hpp index 12c75ea..6524a86 100755 --- a/include/boost/foreach.hpp +++ b/include/boost/foreach.hpp @@ -69,6 +69,7 @@ #include #include #include +#include #include #include #include @@ -129,8 +130,15 @@ namespace foreach // This also tells BOOST_FOREACH to avoid the rvalue/lvalue detection stuff. template struct is_noncopyable - #ifndef BOOST_BROKEN_IS_BASE_AND_DERIVED + #if !defined(BOOST_BROKEN_IS_BASE_AND_DERIVED) && !defined(BOOST_NO_IS_ABSTRACT) + : boost::mpl::or_< + boost::is_abstract + , boost::is_base_and_derived + > + #elif !defined(BOOST_BROKEN_IS_BASE_AND_DERIVED) : boost::is_base_and_derived + #elif !defined(BOOST_NO_IS_ABSTRACT) + : boost::is_abstract #else : boost::mpl::false_ #endif @@ -356,8 +364,11 @@ inline T &derefof(T *t) template struct rvalue_probe { + struct private_type_ {}; // can't ever return an array by value - typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_, int, T>::type value_type; + typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_< + boost::mpl::or_, boost::is_array >, private_type_, T + >::type value_type; operator value_type(); operator T &() const; };