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 32,256 of 33,346   
   =?ISO-8859-1?Q?Daniel_Kr=FCgler?= to Dave Harris   
   Re: stl clear and erase.   
   07 May 12 01:51:05   
   
   From: daniel.kruegler@googlemail.com   
      
   On 2012-05-05 15:08, Dave Harris wrote:   
   > It's also possible because the compiler knows destroying an int is a   
   > no-op. For example:   
   >   
   >       // (I use a wrapper because I'm not sure int::~int() is   
   >       // valid syntax).   
   >       struct Int { int i; };   
   >   
   >       void destroy( Int *p, size_t count ) {   
   >           for (size_t i = 0; i != count; ++i)   
   >               p[i].Int::~Int();   
   >       }   
      
   In regard to your comment in the parentheses: You are right, direct   
   usage of int::~int() is not valid, you either need a type-name or a   
   decltype-specifier for this when referring to a scalar type, see 5.2.4   
   [expr.pseudo] p1:   
      
   "The use of a pseudo-destructor-name after a dot . or arrow -> operator   
   represents the destructor for the non-class type denoted by type-name or   
   decltype-specifier."   
      
   HTH & Greetings from Bremen,   
      
   Daniel Krügler   
      
      
   --   
         [ 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