Boost logo

Boost Users :

Subject: [Boost-users] Boost.Iterator runtime assertion with MSVC
From: Narinder Claire (narinder.claire_at_[hidden])
Date: 2011-07-21 19:21:24


The following piece of code :



typedef std::map<std::string, int> map;
typedef map::const_iterator const_iterator;

struct transformer
    typedef std::string result_type;
    const result_type & operator()(const std::pair<const result_type,
int> & thePair)const
        return thePair.first;

typedef boost::transform_iterator<transformer, const_iterator >

int main()
    map m;

    const_key_iterator key_iterator(m.begin(),transformer());

    // Following 3 lines work fine
    const std::string &temp = *key_iterator;
    std::string::const_iterator it_works = temp.begin();
    std::cout << *it_works;

    // Following 2 lines cause crash when
    // compiled with VS2010 & VS2008
    std::string::const_iterator it_fails = key_iterator->begin();
    std::cout << *it_fails ;



executes fine when compiled with mingw(gcc 4.5.2) and gcc 4.5.2(Ubuntu
11.04) but crashes when compiled with VS2010 & VS2008. The issue seems
to be something about not being allowed to dereference an iterator toa
Can anyone shed any light on this ?
I ensured that language extensions were NOT disabled.


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at