Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: Eyeballs needed on new reference counted pointer template

From: Alex Burton <alexibu(at)mac.com>
Date: Wed Aug 15 2007 - 04:42:49 EDT


Warren,

Looks all right - haven't tested it.
Slight improvements might be made by only testing counted_ to know if it is a non null pointer instead of checking ref_ is set all the time. Like below.
Untested - but if it doesn't work you get the idea. As mentioned by others it is probably not exception safe in assign(T * c) this is best handled using the .swap idiom that is in boost pointers and standard library.

Alex

	void assign(T* c)

{
detach(); counted_ = c; if (c) { refs_ = new size_t(1); } } void assign(const ThisType& other)
{
detach(); counted_ = other.counted_ if (counted_ ) { refs_ = other.refs_; ++(*refs_); } } void detach()
{
if (counted_) if (--(*refs_) == 0)) { delete counted_; delete refs_; } }
-- 
MySQL++ Mailing List
For list archives: 
http://lists.mysql.com/plusplus
To unsubscribe:    
http://lists.mysql.com/plusplus?unsub=lists@pantek.com
Received on Wed Aug 15 04:43:10 2007

This archive was generated by hypermail 2.1.8 : Sun Oct 07 2007 - 10:03:00 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library