Click here to Skip to main content
15,893,564 members
Articles / Programming Languages / C++

A policy based reference counting implementation for compound objects

Rate me:
Please Sign up or sign in to vote.
4.77/5 (13 votes)
26 May 2005CPOL16 min read 33.3K   274   30  
Reference counting smart pointers and handles of various flavours.
////////////////////////////////
// dependency.h

#pragma once
#pragma message( "Compiling " __FILE__ )

#ifndef _CPPRTTI
#error RTTI required: set runtime type ON in your copiler
#endif

//disable unnecessary warnings
#pragma warning(disable: 4250) //inheritance by dominance is by design
#pragma warning(disable: 4100) //unreferenced parameters are by design
#pragma warning(disable: 4189) //unreferenced variable can be by design
#pragma warning(disable: 4201) //unnamed struct and union are by design
#pragma warning(disable: 4512) //unassingable object are by design

//Global symbols
#ifndef interface
#define interface struct
#endif

typedef size_t point_t;

#ifndef SELECTANY_ 
#define SELECTANY_ _declspec(selectany)
#endif

#pragma message( "- Compiling stdlib and CRT" ) 
#include <stdlib.h>
#include <crtdbg.h>
//gererally used files
#include <stdio.h>
#include <stdarg.h>
#include <tchar.h>
#include <typeinfo.h>

#ifndef ASSERT
#define ASSERT _ASSERTE
#ifdef _DEBUG
#define VERIFY(f) ASSERT(f)
#else
#define VERIFY(f) (f)
#endif
#endif

//some STL headers
#pragma message( "- Compiling STL headers" ) 
#include <functional>
#include <utility>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <hash_map>
#include <deque>
#include <stack>
#include <queue>

//some STDX always used stable headers
#include "trace.h"
#include "helpers.h"

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
Italy Italy
Born and living in Milan (Italy), I'm an engineer in electronics actually working in the ICT department of an important oil/gas & energy company as responsible for planning and engineering of ICT infrastructures.
Interested in programming since the '70s, today I still define architectures for the ICT, deploying dedicated specific client application for engineering purposes, working with C++, MFC, STL, and recently also C# and D.

Comments and Discussions