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,580 of 33,346   
   Edward Diener to Nikolay Ivchenkov   
   Re: Can an arbitrary continuous sequence   
   22 Oct 11 14:20:42   
   
   7110a369   
   From: eldiener@tropicsoft.invalid   
      
   On 10/16/2011 9:21 AM, Nikolay Ivchenkov wrote:   
   > Consider the following example:   
   >   
   >     #include   
   >     #include   
   >     #include   
   >   
   >     int main()   
   >     {   
   >         std::vector  vec =   
   >             { "0|0", "0|1", "1|0", "1|1" };   
   >         std::string (*arr)[2] =   
   >             static_cast((void *)vec.data());   
   >   
   >         std::cout<<  arr[1][1]<<  std::endl;   
   >     }   
   >   
   > Are the results of the explicit type conversion (performed by   
   > static_cast) and of the implicit array-to-pointer conversion well-   
   > defined here?   
   >   
   >   
      
   I think the word is "contiguous" sequence, not "continuous" sequence,   
   and since a std::vector is a "contiguous" sequence, you should be fine   
   in your code.   
      
      
   --   
         [ 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