Modify

Opened 10 years ago

#1469 new Bugs

[mpl] nested typedef of set has two different meanings

Reported by: sven.vanechelpoel@… Owned by: Aleksey Gurtovoy
Milestone: To Be Determined Component: mpl
Version: Boost 1.34.1 Severity: Problem
Keywords: Cc:

Description

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

Attachments (0)

Change History (0)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain Aleksey Gurtovoy.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.