Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Standard C++ Library Changes: Visual C++ .NET 2003

If you are upgrading a program that uses Standard C++ Library code that compiled in Visual C++ 6.0, you should be aware of the following issues:

The names for some of the types defined by the Standard C++ Library reverse_iterator class have changed. Also, there are different template arguments for this class.

The following sample compiled in Visual C++ 6.0, but fails in the current version:

#include <iterator>
#include <vector>
typedef std::iterator<std::random_access_iterator_tag, char, int> random_it;

int main( )
{
   char c;
   
   // too many template args for VC7
   typedef std::reverse_iterator< random_it, char, char&, char *, int > rev_it; 
   rev_it::reference_type x = c;
   rev_it::pointer_type y = 0;
   rev_it::iter_type z;

   /*
   // try the following code instead
   typedef std::reverse_iterator< random_it > rev_it;
   rev_it::reference a = c;
   rev_it::pointer b = 0;
   rev_it::iterator_type c1;
   */
}

In some Standard C++ Library classes, iterators are no longer defined as pointer types.

The following sample compiled in Visual C++ 6.0, but fails on the indicated lines in the current version:

#include <string>
#include <vector>
#include <algorithm>

bool pred(int i) { 
   return true; 
};

int main()
{
   std::string str("test");
   const char *pszstr = str.begin();       // LINE 8: INCORRECT
   const char *pszStr2 = str.c_str();      // OK
   const char *pszStr3 = &(*str.begin());  // OK

   std::vector<int> v;
   int *pint = std::remove_if(v.begin(), v.end(), pred);   // LINE 13: INCORRECT
   std::vector<int>::iterator iint = std::remove_if(v.begin(), v.end(), pred);   // OK
}

The Standard C++ Library definition of _MIN and _MAX changed from:

#define _MAX   _cpp_max
#define _MIN   _cpp_min

to:

#define _MAX   (max)
#define _MIN   (min)

This makes definitions of std::_MIN invalid.

The following sample compiled in Visual C++ 6.0, but fails on the indicated line in the current version:

#include <xutility>
#include <stdlib.h>
using namespace std;
int main()
{
   std::_MAX(3,4);   // error
   _MAX(4,5);
}
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft