Smart Pointers and Stuff

Questions, comments, and news on the server side plug-ins and it's API
Post Reply
Private First Class
Private First Class
Posts: 211
Joined: Sat Apr 23, 2005 3:13 am

Smart Pointers and Stuff

Post by Enigma » Sun Aug 03, 2008 11:48 pm

This is just a small collection of functions and classes that I have written and may be of use to someone. The name of the header file could use a better name, and if your compiler doesn't support partial template specialization then you are out of luck.

Noncopyable class

This class is meant to be subclassed by classes that shouldn't be copyable. Its copy constructor and assignment operator are both declared private.

Type Traits

I have a bunch of type traits classes that I have been writing on and off for some time, mainly as educational exercises, but only a small subset of what I have written is included here.


Removes top-level const qualifiers. Actually it just typedefs the type without the const qualifier. For instance, bzf::remove_const<const int>::Type will be of type int.


Removes the volatile qualifier from a type.


Removes const and volatile qualifiers.


This is a type trait to find out if an unknown type is one of the bzfs containers. Usage: bzf::is_bz_container<T>::value. If T is a bzfs container, value will be true. The remove_const and remove_volatile classes were included because this class requires them.


This function will properly delete anything, except arrays. If the type is one of the bzfs containers, it will call the proper delete functions, such as bz_deleteIntList(). If it is any other type, the function will just call delete.


These functions are just for convenience.


This is a simple, noncopyable smart pointer class. I wrote it as an academic exercise while reading Modern C++ Design and C++ Templates: The Complete Guide, and it is basically the same as std::auto_ptr, except it does not transfer ownernship. The local_ptr class also uses the bz_delete() function to properly delete bzfs containers.
(5.99 KiB) Downloaded 153 times

Post Reply