home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 31,513 of 33,346   
   Seungbeom Kim to nmm1@cam.ac.uk   
   Re: Using the STL for scientific program   
   01 Oct 11 15:36:01   
   
   From: musiphil@bawi.org   
      
   On 2011-09-30 11:10, nmm1@cam.ac.uk wrote:   
   >   
   >> a lot of std::vector (internally), std::pair,   
   >   
   > But do those really help compared with rolling your own?  My point is   
   > not that they don't work, but what practical benefits they convey.   
   >   
   > When writing classes that needed vectors, I discovered that using   
   > std::vector didn't simplify the code significantly over ordinary   
   > arrays/pointers or provide significant extra checking.  It does free   
   > space when writing a simple vector declaration and using exceptions to   
   > jump out, but that's about all I found.   
      
   Then is new[]/delete[] your preferred choice?   
   What benefits does it bring, and why would you prefer it to std::vector?   
      
   >> IO streams for outputs (IO manipulators),   
   >   
   > Are they really a help compared to ?  I tried hard to use them,   
   > found them painful, and then queried it in a C++ expert forum, only to   
   > discover that even they found  easier to use and more flexible.   
   > Indeed, I found them harder to use than Fortran formatted I/O!   
      
   Sometimes IOstreams are tedious and too verbose, but I realise I'm so   
   grateful to them when I'm using cstdio (or any other reporting/logging   
   facility based on v*printf) and can never figure out what format   
   specifiers to use for pid_t or time_t or uintptr_t portably, or when   
   they break all over the code as I port it to a different platform.   
      
   (Yes, C99 helps a bit with new length modifiers, but I have experienced   
   C++ compilers which don't like them and give warnings in C++ mode. So,   
   given a piece of old code that uses "%lu" with size_t, I have to choose   
   between:   
   (1) using "%zu" (with the risk of warnings),   
   (2) casting size_t to unsigned long (with some risk of losing some big   
   values, although that's rare), and   
   (3) casting size_t to unsigned long long and using "%llu" (again with   
   the risk of warnings, because C++03 doesn't have long long officially).   
   What a great deal of thinking for such a trivial task as printing out   
   a number. (sigh))   
      
   --   
   Seungbeom Kim   
      
      
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca