C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Smart pointer without templates possible ?

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
lothar.behrens@lollisoft.
Guest





PostPosted: Fri Apr 29, 2005 1:10 pm    Post subject: Smart pointer without templates possible ? Reply with quote



Hi,

a long time ago I had implemented my version - or attempt - of a smart
pointer.
It is not well and most books I have read afterwards are using
templates :-(

It is macro based and now I must see, that there are some ugly code
constructs,
that I like to avoid in future.

This is the macro (not complete):

#define UAP(interface, Unknown_Reference)
class UAP##Unknown_Reference {
public:
UAP##Unknown_Reference();
UAP##Unknown_Reference(const UAP##Unknown_Reference& _ref);
void operator=(const UAP##Unknown_Reference& _ref);
interface* LB_STDCALL operator -> () const;
interface* LB_STDCALL operator -> ();
interface* LB_STDCALL operator == (const interface* b);
interface* LB_STDCALL operator != (const interface* b);
}

The problem is, if I use it for two pointers of same type, I cannot
compare
it like this:

UAP(lb_I_String, s1)
UAP(lb_I_String, s2)

// Some code to initialize s1 and s2

if (s1 == s2)
printf("Equal.n");
else
printf("Not equal.n");

I thought, if I use the interface as like this 'UAP##interface' instead
of
'UAP##Unknown_Reference', I will get trouble in double class
definitions.

Would it be possible to solve this by deriving from a base 'UAPBase'
having
the implementations for operator ==, !=, < and so on ?

The implementation of the base, then calls functions like equal...

Thanks

Lothar

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.