Showing posts with label Visual Studio. Show all posts
Showing posts with label Visual Studio. Show all posts

Friday, September 12, 2008

Using an STL list with current and next iterators

General algorithm for using a "current" and a "next" iterator on an STL list, which doesn't provide a convenient next() method (random-access containers such as vector do):


std::list<Foo>::iterator currIter, nextIter;

currIter = list.begin();

while(currIter != list.end())
{
currIter->doStuff(); // do something with the curr item

nextIter = ++currIter; //advance the iter and set it to next
if(nextIter != list.end()) // still safe to use next item
{
nextIter->doStuff(); // do something with the next item
}
}

Sunday, May 11, 2008

Deleting the .ncb file fixes Intellisense Crash in VS 2008 Express

Argh! Visual Studio 2008 Express was crashing every time I right-clicked on any code belonging to the C++ template class declaration I was writing for my C++ course assignment. Googling "2008 intellisense crash" turned up a link to an MSDN forum discussion about VS crash when updating intellisense, wherein one of the posters suggested deleting the .ncb file. Before launching my project for the nth time, I deleted the .ncb file. Voila! Intellisense works again.