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,471 of 33,346   
   Leigh Johnston to evansl   
   Re: PreallocatedArray code review   
   11 Jul 12 11:20:43   
   
   From: leigh@i42.co.uk   
      
   On 10/07/2012 14:26, evansl wrote:   
   > On Monday, July 9, 2012 6:02:40 PM UTC-5, Jimmy H. wrote:   
   >   
   >> So I wrote a collection class that like std::array, it stores its   
   >> elements as values in the objects without using indirection, but   
   >> also allows less than the entire allocation to be used. I'm sure   
   >> I've made C ++ newbie errors writing this, so could someone help me   
   >> find them?   
   >>   
   > [snip]   
   >>   
   >> template<class T, size_t N>   
   >> class PreallocatedArray {   
   >>     char memory[sizeof(T) * N];   
   >>     size_t valid_size;   
   >>   
   > [snip]   
   > This memory buffer only has an alignment of 1 (for char).   
   > Shouldn't the alignment be at least as stringent   
   > as that for T?   
      
   Yes it should.  Check out my vecarray container which does something   
   similar but with correct alignment.   
      
   http://i42.co.uk/stuff/vecarray.htm   
      
   /Leigh   
      
      
   --   
         [ 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