Question fstream logistics
The following code compiles with no errs and works.
However my VC Pro 2005 Intellisense shows a bunch of stuff but does not show anything for-> ::in <-OR-> ::out ON <-std::fstream::
I'm wondering has the template been upgraded (?) or is this just beyond the Intellisense capability ?
When I look in the include files I can't spot them either, but it is compiling (?). I'm not that good at reading ATL so maybe I'm just not spotting them.
Code:
std::fstream FileObj;
FileObj.open("TempFile.txt", std::fstream::in | std::fstream::out | std::fstream::app);
FileObj << '\n' << _T("Whatever Text") << '\n' ;
FileObj << _T("Whatever other Text") << '\n' ;
FileObj.close();
Re: Question fstream logistics
If you trace the inheritance hierarchy of std::fstream, you will find that it is a subclass of std::ios_base, in which these open modes are declared.
Re: Question fstream logistics
Quote:
Originally Posted by
J_W
The following code compiles with no errs and works.
However my VC Pro 2005 Intellisense shows a bunch of stuff but does not show anything for-> ::in <-OR-> ::out ON <-std::fstream::
Intellisense is just a tool, a tool that can have bugs -- it isn't a C++ compiler.
C++ is a language with complex rules, so it is unlikely that a non-compiler tool that tries to follow these rules and parse source files will get everything correct. Even commercial C++ code parsers and tag generators that are reportedly superior to Intellisense won't get it right all the time (see Visual Assist, for example)
Regards,
Paul McKenzie
Re: Question fstream logistics
Quote:
Originally Posted by
laserlight
If you trace the inheritance hierarchy of std::fstream, you will find that it is a subclass of std::ios_base, in which these open modes are declared.
Thank you for that verification. I should have done that, I know from the past that can be quite tedious and time consuming, but no excuse.
Quote:
Originally Posted by
Paul McKenzie
Intellisense is just a tool, a tool that can have bugs -- it isn't a C++ compiler.
C++ is a language with complex rules, so it is unlikely that a non-compiler tool that tries to follow these rules and parse source files will get everything correct. Even commercial C++ code parsers and tag generators that are reportedly superior to Intellisense won't get it right all the time (see Visual Assist, for example)
Regards, Paul McKenzie
I figured that might be the case, but glad you verified it. For some reason the forum will not allow me to give you a reputation point for you answer. I surmise you give a lot of good answers and it won't allow past a certain quota.
Thanks again to both of you.
Re: Question fstream logistics
Also, you shouldn't be using _T(). Formatted output methods of std::fstream always works on narrow strings/characters.
gg
Re: Question fstream logistics
Quote:
Originally Posted by
Codeplug
Also, you shouldn't be using _T(). Formatted output methods of std::fstream always works on narrow strings/characters. gg
Thanks that's a good point. I have another question on that subject.
1. Do a lot of folks still consider the recompile portability of TCHAR a good thing now days or are more folks leaning towards explicit types for each define?
2. When considering buffer overrun safety what (or does) the std:: templates have in this area. Or should I stick with the newer string safe handling routines like StringCchLength etc
Re: Question fstream logistics
TCHAR's solve a very specific problem and aren't needed in new development. You can read about it in this thread: http://social.msdn.microsoft.com/For...-a1d41beb05fb/
Personally, I don't use Win32 "safe" functions. Just std::wstring, std::vector<> etc.
gg
Re: Question fstream logistics
Quote:
Originally Posted by
Codeplug
Wow that is one of the better threads I've ever read on this. Thanks for fronting it to me. The answers where mixed as usual but very thorough and informative.