STL string and const_cast 
Author Message
 STL string and const_cast

#include <string>
using namespace std;

void foo(const string& s)
{
    // <foo> is not supposed to modify the parameter <s>.
    // Assume <foo> is exported from a third party DLL.

Quote:
}

void main()
{
    string s = "Test";
    foo(s);
    // <s> holds "TEST" here.

Quote:
}

Am I doing anything wrong here or is this a complier bug
(MS VC 6.0 w/ sp5, Win 2K w/ sp1) or the STL bug.

Any help is much appreciated.

George

PS: I do have a workaround using _bstr_t.



Sat, 16 Apr 2005 12:39:54 GMT  
 STL string and const_cast
Pl. ignore. Figured it.

#include <string>
using namespace std;

void foo(const string& s)
{
    // <foo> is not supposed to modify the parameter <s>.
    // Assume <foo> is exported from a third party DLL.

Quote:
}

void main()
{
    string s = "Test";
    foo(s);
    // <s> holds "TEST" here.

Quote:
}

Am I doing anything wrong here or is this a complier bug
(MS VC 6.0 w/ sp5, Win 2K w/ sp1) or the STL bug.

Any help is much appreciated.

George

PS: I do have a workaround using _bstr_t.



Sun, 17 Apr 2005 09:36:25 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Warnings using STL Map<string,string>

2. VARIANT String assign to STL string

3. Does the STL string support unicode strings?

4. Error with const_cast<...>, porting from a VC6 project

5. const_cast behavior

6. how to avoid const_cast

7. again on const_cast and .c_str()

8. Bug in .net string/stl

9. STL String problem in VC7

10. STL strings and .NET

11. BSTR , CSTring and STL string

12. STL map<string, IHTMLElement*> Elements

 

 
Powered by phpBB® Forum Software