Author Topic: C++ STL iterator is not recognized  (Read 14837 times)

jej45

  • Community Member
  • Posts: 32
  • Hero Points: 1
C++ STL iterator is not recognized
« on: October 26, 2015, 12:55:17 PM »
consider the following snippet:
#include <map>

std::map<int, int> aMap;
std::map<int, int>::iterator itr = aMap.begin();
itr-> // get message "attempt to use operator '->', but itr is not a pointer"


Dennis

  • Senior Community Member
  • Posts: 3954
  • Hero Points: 515
Re: C++ STL iterator is not recognized
« Reply #1 on: October 26, 2015, 03:33:16 PM »
I was able to reproduce this on Windows using a GNU-C project.  I'll look into it.

Dennis

  • Senior Community Member
  • Posts: 3954
  • Hero Points: 515
Re: C++ STL iterator is not recognized
« Reply #2 on: October 26, 2015, 08:58:08 PM »
This is fixed for the next drop.

jej45

  • Community Member
  • Posts: 32
  • Hero Points: 1
Re: C++ STL iterator is not recognized
« Reply #3 on: October 27, 2015, 10:07:57 AM »
thanks

jej45

  • Community Member
  • Posts: 32
  • Hero Points: 1
Re: C++ STL iterator is not recognized
« Reply #4 on: October 27, 2015, 02:36:09 PM »
BTW can you verify for the other containers, typedef and auto? Guess that I am being greedy.
E.g.
typedef std::vector<int>::iterator vecItr;
using vecItr = std::list<int>

std::list<int> aList;
auto itr = aList.begin();

auto itr = std

also,

Dennis

  • Senior Community Member
  • Posts: 3954
  • Hero Points: 515
Re: C++ STL iterator is not recognized
« Reply #5 on: October 27, 2015, 03:27:23 PM »
Tested, worked.  The local using statement uncovered a small Symbol Coloring bug which is now fixed.

jej45

  • Community Member
  • Posts: 32
  • Hero Points: 1
Re: C++ STL iterator is not recognized
« Reply #6 on: October 27, 2015, 03:33:34 PM »
thanks again   :)

jej45

  • Community Member
  • Posts: 32
  • Hero Points: 1
Re: C++ STL iterator is not recognized
« Reply #7 on: November 02, 2015, 02:45:48 PM »
did this make it into RC4?

Dennis

  • Senior Community Member
  • Posts: 3954
  • Hero Points: 515
Re: C++ STL iterator is not recognized
« Reply #8 on: November 02, 2015, 04:55:53 PM »
Yes, the fixes were in RC4, I just retested them.  I had to clean up your second example a bit, but these cases do work.  There may be some residual problems with newer Visual Studio configurations which I did not have available for testing, but I did confirm that all these examples do work when using Visual Studio 2010 includes.

Code: [Select]
#include <map>
void test33() {

   std::map<int, int> aMap;
   std::map<int, int>::iterator itr = aMap.begin();
   itr->; // get message "attempt to use operator '->', but itr is not a pointer"

   typedef std::vector<std::string>::iterator vecItr;
   using listItr = std::vector<std::string>::iterator;

   std::list<std::string> aList;
   auto itr2 = aList.begin();
   itr2->clear();
   
   vecItr vitr;
   vitr->app;

   listItr litr;
   litr->;
}

jej45

  • Community Member
  • Posts: 32
  • Hero Points: 1
Re: C++ STL iterator is not recognized
« Reply #9 on: November 02, 2015, 05:10:01 PM »
OK. I'm probably doing something wrong.  I am running the linux 64-bit on Red Hat Enterprise Linux Server release 6.2 We aer using gcc 4.4.4. Will try it on Windows.

Dennis

  • Senior Community Member
  • Posts: 3954
  • Hero Points: 515
Re: C++ STL iterator is not recognized
« Reply #10 on: November 05, 2015, 01:31:24 AM »
I was able to reproduce the problem on Windows when using a Visual Studio 2015 compiler tag file.  They had done some more gyrations with the STL map template class that required more attention to handle.

I was not able to reproduce the problem on CentOS 6.6 with GCC 4.4.4 (the closest I had to RHEL 6.2 available).  However, you should verify that your project is configured to use the GCC 4.4.4 tag file by default (or the "Unix Includes" tag file, which should include the 4.4.4 headers).  Do this by checking Project > Project Properties > Compile/Link tab.  And also verify that this tag file is built.  Tools > Tag Files... > (select C/C++ compiler tag file) > Rebuild tag file > uncheck retag modified only, and wait for it to finish before testing.

The fix for Visual Studio 2015 will go into a future hot fix for SlickEdit 2015.  It may also help with other STL implementations.