CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2011
    Posts
    30

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    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.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  3. #3
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Question fstream logistics

    Quote Originally Posted by J_W View Post
    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.

  4. #4
    Join Date
    Jun 2011
    Posts
    30

    Re: Question fstream logistics

    Quote Originally Posted by laserlight View Post
    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 View Post
    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.

  5. #5
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Question fstream logistics

    Also, you shouldn't be using _T(). Formatted output methods of std::fstream always works on narrow strings/characters.

    gg

  6. #6
    Join Date
    Jun 2011
    Posts
    30

    Re: Question fstream logistics

    Quote Originally Posted by Codeplug View Post
    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

  7. #7
    Join Date
    Nov 2003
    Posts
    1,902

    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

  8. #8
    Join Date
    Jun 2011
    Posts
    30

    Re: Question fstream logistics

    Quote Originally Posted by Codeplug View Post
    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
    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
  •  





Click Here to Expand Forum to Full Width

Featured