[Boost-bugs] [Boost C++ Libraries] #1469: [mpl] nested typedef of set has two different meanings

Subject: [Boost-bugs] [Boost C++ Libraries] #1469: [mpl] nested typedef of set has two different meanings
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2007-11-22 13:25:20


#1469: [mpl] nested typedef of set has two different meanings
------------------------------------------+---------------------------------
 Reporter: sven.vanechelpoel_at_[hidden] | Owner: agurtovoy
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: mpl
  Version: Boost 1.34.1 | Severity: Problem
 Keywords: |
------------------------------------------+---------------------------------
 This problem was diagnosed by Steve Watanabe after my posting on the
 developer list (see
 http://thread.gmane.org/gmane.comp.lib.boost.devel/168339/focus=168366)

 Basically the following doesn't compile:

 {{{
 #include <boost/mpl/set.hpp>
 #include <boost/mpl/vector.hpp>
 #include <boost/mpl/copy.hpp>
 #include <boost/mpl/insert.hpp>
 #include <boost/mpl/inserter.hpp>

 using namespace boost::mpl;

 template<
   typename T
> >
 struct as_set :
   copy<
     T
   , inserter<
       set<>
     , insert< _1, _2 >
>
>
 {};

 typedef set<int,char> a_set;
 typedef vector<int,int,char> a_vector;
 typedef as_set< a_set >::type set_as_set;
 typedef as_set< a_vector >::type vector_as_set;

 typedef next< begin< a_set >::type >::type
 THIS_IS_OK;
 typedef next< next< begin< a_set >::type >::type >::type
 THIS_IS_OK_AS_WELL;
 typedef next< begin< a_vector >::type >::type
 THIS_IS_OK_TOO;
 typedef next< begin< set_as_set >::type >::type
 THIS_WORKS_TOO;
 typedef next< next< begin< set_as_set >::type >::type >::type
 THIS_FAILS;
 typedef next< next< begin< vector_as_set >::type >::type >::type
 THIS_FAILS_TOO;
 }}}

 Steve Watanabe diagnosed this to be a problem of mpl::set using the nested
 typedef 'type' for two different purposes: one as an alias of the set<>,
 the other refering to the item type. The result is that upon iteration the
 termination condition isn't recognized and the iterator blows up

--
Ticket URL: <http://svn.boost.org/trac/boost/ticket/1469>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.


This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:57 UTC