Boost logo

Boost :

From: Maksym Motornyy (mmotorny_at_[hidden])
Date: 2005-06-01 04:55:57


Hi all,

It is know that typedef in C++ is actually an alias, i.e. it doesn't
create new distinguishable type. Sometimes this causes problems.
Consider following example:

typedef int handle;

template < typename Value >
void write( const Value &value );

void write< int >( const int &value )
{
     // do processing for int
}

void write< handle >( const handle &value )
{
     // we wanted to have separate processing for handle,
     // but we get only compilation error :(
}

In my projects I resolve such situations as the following:

class handle_tag
{
};

typedef tagged< int, handle_tag > handle;

Then everything works as expected. "tagged" class is actually a wrapper
that mimics fundamental type behaviour. Also I have specialization for
pointers.

Is anyone interested in such solution of given problem? Is it worth to
be part of Boost?

Sincerely,
Maksym Motornyy.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk