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 

Template to remove reference.

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





PostPosted: Fri Oct 28, 2005 4:16 pm    Post subject: Template to remove reference. Reply with quote



Hi,

I need a template that will remove references from a type. Suppose the
template I need is named Drop_ref. I'd like to do something like this
.. . .

Drop_ref<SomeClass &>::type InstanceOfSomeClass;

would be equivalent to

SomeClass InstanceOfSomeClass;


Unfortunately, it must work with a C++ compiler that does not have
partial template specialization. Microsoft has yet to bring Embedded
Visual C++ up to ISO standards. If someone could post a work around
I'd be very appreciative.

Back to top
mlimber
Guest





PostPosted: Fri Oct 28, 2005 6:44 pm    Post subject: Re: Template to remove reference. Reply with quote



[email]jeff_d_harper (AT) hotmail (DOT) com[/email] wrote:
Quote:
Hi,

I need a template that will remove references from a type. Suppose the
template I need is named Drop_ref. I'd like to do something like this
. . .

Drop_ref<SomeClass &>::type InstanceOfSomeClass;

would be equivalent to

SomeClass InstanceOfSomeClass;


Unfortunately, it must work with a C++ compiler that does not have
partial template specialization. Microsoft has yet to bring Embedded
Visual C++ up to ISO standards. If someone could post a work around
I'd be very appreciative.

See the implementations in Boost.TypeTraits (http://boost.org) and Loki
([url]http://sourceforge.net/projects/loki-lib/)[/url]. They both have some tricks
to make it work with VC++ 6.

Cheers! --M


Back to top
Victor Bazarov
Guest





PostPosted: Fri Oct 28, 2005 6:55 pm    Post subject: Re: Template to remove reference. Reply with quote



mlimber wrote:
Quote:
jeff_d_harper (AT) hotmail (DOT) com wrote:
[...request that could be easily satisfied with partial specialisation...]
Unfortunately, it must work with a C++ compiler that does not have
partial template specialization. Microsoft has yet to bring Embedded
Visual C++ up to ISO standards. If someone could post a work around
I'd be very appreciative.


See the implementations in Boost.TypeTraits (http://boost.org) and Loki
([url]http://sourceforge.net/projects/loki-lib/)[/url]. They both have some tricks
to make it work with VC++ 6.

VC++ 6 is actually more advanced than Embedded VC++, or so I heard.

Back to top
jeff_d_harper@hotmail.com
Guest





PostPosted: Fri Oct 28, 2005 7:38 pm    Post subject: Re: Template to remove reference. Reply with quote

I'd already checked out Boost. Unfortunately, it looks like it is not
possible to remove a reference with boost unless the compiler supports
partial template specialization. Or, a macro is used to setup type
traits for user defined types.

http://www.boost.org/doc/html/boost_typetraits/category.html#transform.broken_compiler_workarounds_

At your suggestion I looked at Loki. Unfortunately, it doesn't look
like the TypeTraits<T>::ReferredType is implemented in the VC6 version
of Loki.

In fact, when I grepped the VC6 Loki header files for ReferredType, I
found this comment:

//TODOSGB None of the parameter types are defined inside of TypeTraits,
e.g. PointeeType, ReferredType, etc...

I will probably implement a solution similar to Boost's "broken
compiler work around" where I use a macro to setup a type trait for all
my UDTs.

I look forward to the day when I no longer have to worry about how
complete my compiler's template support is.

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.