Hello
The following piece of code :
____________________
#include<string>
#include<map>
#include<iostream>
#include<iterator>
#include
typedef std::map map;
typedef map::const_iterator const_iterator;
struct transformer
{
typedef std::string result_type;
const result_type & operator()(const std::pair & thePair)const
{
return thePair.first;
}
};
typedef boost::transform_iterator
const_key_iterator;
int main()
{
map m;
m["one"]=1;
m["two"]=2;
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
string.
Can anyone shed any light on this ?
I ensured that language extensions were NOT disabled.
Rgds
N