Topic: Proposal: boost::placed_ptr<> smart pointer


Author: philippeb@videotron.ca ("Philippe A. Bouchard")
Date: Mon, 9 Sep 2002 17:31:28 +0000 (UTC)
Raw View
Garry Lancaster wrote:

> What makes this different to other reference-counted smart
> pointers?

Given:
- T -> any type
- other smart pointer can have:
        - 2 memory allocations when constructed:
                - 1 for the object;
                - 1 for the counter.

This smart pointer has the following properties:
- sizeof(placed_ptr<T>) == sizeof(T *);
- 1 malloc call per dynamic object allocation.

Secondary effects:
- system memory map is twice smaller:
        - faster lookups for other malloc()s;
        - requires less memory;
- large containers of this type (ex.: list< placed_ptr<T> >) are favoured
compared to other smart pointers having sizeof(T *) x 2.

Time drawback (not a heavy one - demontrated in benchmark.4.txt):
- dereferencing a pointer to an object with polymorphic hierarchy.

> (Your link is to source files and benchmarks. I need to be
> interested in the concept first before I wade through all
> that. Maybe I'm uniquely lazy, but I suspect I'm not alone. ;-)

My mistake, I'm sorry.



Regards,

Philippe A. Bouchard

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: glancaster@ntlworld.com ("Garry Lancaster")
Date: Sat, 7 Sep 2002 22:44:08 +0000 (UTC)
Raw View
"Philippe A. Bouchard":
>     (I've renamed ptr<> to placed_ptr<>... cleaner for a proposal).
>
>     I would like to propose placed_ptr.hpp as a new type of reference
count
> smart pointer:
>     http://groups.yahoo.com/group/boost/files/ptr/

What makes this different to other reference-counted smart
pointers?

(Your link is to source files and benchmarks. I need to be
interested in the concept first before I wade through all
that. Maybe I'm uniquely lazy, but I suspect I'm not alone. ;-)

Kind regards

Garry Lancaster
Codemill Ltd
Visit our web site at http://www.codemill.net


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: philippeb@videotron.ca ("Philippe A. Bouchard")
Date: Thu, 5 Sep 2002 18:04:33 +0000 (UTC)
Raw View
Hi,

    (I've renamed ptr<> to placed_ptr<>... cleaner for a proposal).

    I would like to propose placed_ptr.hpp as a new type of reference count
smart pointer:
    http://groups.yahoo.com/group/boost/files/ptr/

    Why I am proposing it to comp.std.c++?  Because only the compiler can
determine if the classes are polymorphic or not and could instanciate the
proper partly specialized placed_ptr<> by itself.  reinterpret_cast<>s will
still be possible because sizeof(placed_ptr<T, simple_tree>) ==
sizeof(placed_ptr<T, complex_tree>) and the allocated pointee uses the same
header; only get_count(), reset() & ~ptr() members differ.

    I am planning to add placed_ptr<>::operator delete(void *) as a new
member to disable destroy explicitly cyclic pointers.



Thanks,

Philippe A. Bouchard

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]