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,431 of 33,346    |
|    =?ISO-8859-1?Q?Daniel_Kr=FCgler?= to All    |
|    Re: question: shared pointers with custo    |
|    29 Aug 11 05:32:21    |
   
   beb187d9   
   From: daniel.kruegler@googlemail.com   
      
   Am 28.08.2011 20:17, schrieb Andrew:   
   > I am writing a uuid class. It uses the native WIN32 API on windoze and   
   > uses a C uuid library otherwise. The uuid library header file fwd   
   > declares uuid_t and all the functions take a pointer to uuid_t. Hence   
   > uuid_t does not need to be defined, a fwd-declare is enough. The   
   > details are in the C implementation, the header file is hiding the   
   > implementation details (quite right too).   
   >   
   > The problem I have is that my uuid objects need to exist inside STL   
   > containers so they will be copied. I need to ensure that the memory   
   > allocated by the uuid library is only deallocated once. So I thought I   
   > would be able to make the uuid_t pointer a shared pointer with a   
   > custom deleter. The custom deleter uses uuid_destroy(uuid_t*).   
      
   At this point I'm not sure whether I understand your approach correctly.   
   What does "make the uuid_t pointer a shared pointer" mean precisely?   
      
   > However, I am getting a massive compilation error message during the   
   > parsing of some custom deleter header file that is getting pulled in   
   > somehow. The error message makes me think that the use of a custom   
   > deleter requires that the type be fully known. The error message   
   > includes this:   
   >   
   > /usr/local/boost/include/boost/checked_delete.hpp:32: error: invalid   
   > application of 'sizeof' to incomplete type 'uuid_t'   
   >   
   > I know this is boost but surely the same applies for the equivalent   
   > smart pointers in TR1.   
   >   
   > Can anyone comment on this please?   
      
   You need to provide at least the minimum code necessary to reproduce the   
   problem. I think this should work, at least if I understand your idea   
   correctly. E.g. using the current boost library 1.47.0 the following   
   code compiles successfully with gcc 4.7.0:   
      
   extern "C" {   
      
   struct uuid_t;   
      
   uuid_t* uuid_create();   
      
   void uuid_destroy(uuid_t*);   
      
   }   
      
   #include
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca