-
May 3rd, 2013, 08:29 PM
#1
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-> :ut 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();
Last edited by J_W; May 3rd, 2013 at 08:47 PM.
Reason: clarity
-
May 4th, 2013, 12:39 AM
#2
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.
-
May 4th, 2013, 07:05 AM
#3
Re: Question fstream logistics
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-> : ut 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
Last edited by Paul McKenzie; May 4th, 2013 at 07:09 AM.
-
May 4th, 2013, 08:38 AM
#4
Re: Question fstream logistics
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.
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.
-
May 6th, 2013, 10:52 AM
#5
Re: Question fstream logistics
Also, you shouldn't be using _T(). Formatted output methods of std::fstream always works on narrow strings/characters.
gg
-
May 6th, 2013, 08:12 PM
#6
Re: Question fstream logistics
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
-
May 7th, 2013, 10:42 AM
#7
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
-
May 7th, 2013, 01:50 PM
#8
Re: Question fstream logistics
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.
Last edited by J_W; May 7th, 2013 at 01:51 PM.
Reason: spelling
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|