Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Visual Studio 8 deprecates functions in ::std :-(
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Michi  
View profile  
 More options Nov 17 2005, 7:06 pm
Newsgroups: comp.lang.c++.moderated
From: "Michi" <mi...@zeroc.com>
Date: 17 Nov 2005 19:06:43 -0500
Local: Thurs, Nov 17 2005 7:06 pm
Subject: Visual Studio 8 deprecates functions in ::std :-(
Visual Studio 8 has introduced some interesting warnings. For example,
the expression

::std::equal(m.begin(), m.end(), p)

raises the following warning:

C:\Program Files\Microsoft Visual Studio 8\VC\include\xutility(2674) :
warning C4996: 'std::_Equal' was declared deprecated
        C:\Program Files\Microsoft Visual Studio
8\VC\include\xutility(2661) : see declaration of 'std::_Equal'
        Message: 'You have used a std:: construct that is not safe. See
documentation on how to use the Safe Standard C++ Library'

Wow. Thanks a lot. The same thing happens for a whole raft of other
standard functions, such as copy, set_difference, replace, remove,
merge, etc.

Note the interesting wording: 'std::_equal' was declared deprecated. I
was under the distinct impression that only the C++ standards committee
could deprecate anything in the std namespace...

The work-around is not pretty either. You have to basically redefine
all the affected templates:

namespace PortabilityHacks
{
    template<class InputIterator1, class InputIterator2>
    bool
    equal(InputIterator1 first1, InputIterator1 last1, InputIterator2
first2)
    {
#if _WIN32 && _MSC_VER == 1400
        return ::stdext::unchecked_equal(first1, last1, first2);
#else
        return ::std::copy(first1, last1, first2);
#endif
    }

}

The fact that unchecked_equal() isn't documented doesn't help either.
(Although, to be fair, some of the other "deprecated" templates do have
documentation for the checked and unchecked versions in the stdext
namespace.)

Having written the workaround, I can go and add the PortabilityHacks
namespace to all points where I call one of the standard template
functions that MS have decided to deprecate. My big thanks for this
change go to the MS C++ team: you have just broken my code in many
hundreds of places :-(

I can disable the warning by setting the warning level to 4, but that
doesn't really help me. For one, I don't like to disable warnings;
certainly not with a pragma in a header file because that affects all
the customer code that includes my header file, and also not with a
compiler option. I like my code to compile clean, without warnings.

If this misfeature is the Visual C++ team's idea of standard
compliance, I'm not impressed :-(

Michi.

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.