473,320 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Template to remove reference.

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.

Oct 28 '05 #1
3 2972
je***********@hotmail.com wrote:
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
(http://sourceforge.net/projects/loki-lib/). They both have some tricks
to make it work with VC++ 6.

Cheers! --M

Oct 28 '05 #2
mlimber wrote:
je***********@hotmail.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
(http://sourceforge.net/projects/loki-lib/). 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.
Oct 28 '05 #3
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_...r_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.

Oct 28 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: mrstephengross | last post by:
I'd like to know if there's a standard way that the compiler interprets a template argument. That is, let's say you pass a Foo instance as a template argument to some function. Is the instance...
3
by: Le, Thanh-Nhan | last post by:
Hi, How can I remove a reference to a COM Dll? I want to add reference to new version of this dll. Thanks Nhan
11
by: Niels Dekker - no reply address | last post by:
The following attempt to pass my template "Base" as a template template argument was rejected by Microsoft VC++ 8.0 (2005), while it still works on VC++ 7.1 (2003). Is it correct C++? And is...
14
by: SoilMan | last post by:
Consider the following: class xyz { public: template <typename T> void foo(T x) { cout << "foo<T> " << x << endl; }
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
7
by: Michal Nazarewicz | last post by:
Let say I have a class template Set which represent set of objects of given type, and a struct template Pair representing an ordered pair, ie: #v+ template<class T> class Set { /* ......
7
by: gustavo.scotti | last post by:
Hi. What happens if a given template typename T is int& and you need to reference an int pointer, or even an int? e.g: template <typename T> void do_something( void *ptr, void(*funct)(T...
5
by: colin | last post by:
Hi, I need to cache various resource objects such as images for example, wich might be referenced from multiple objects (wich could be considered documents for ease of discusion) and the idea is...
1
by: Shaft11 | last post by:
I was creating fields on the table of my database. I accidentlly named a field, "MonthNAme" I now need the function, "MonthName". I deleted "MonthNAme" from the table, however VBA still has a...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.