473,387 Members | 1,344 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,387 software developers and data experts.

Templates in .NET

I'm attempting to convert an existing VC6++ project to .NET.

The project makes use of Microsoft's old VisSDK and this uses templates all
over the place, generating 100's of errors.

One common error is to do with this new 'typename' keyword - are there any
#pragma's, or compiler options, that force the compiler to use the old method
?

Whilst I've used templates, I've never designed one myself and am a bit
lost. For example, I get the following warning :-

c:\Projects\VisSDK\inc\VisStlWrappers.h(163) : warning C4346:
'std::map<_Kty,_Ty,_Pr,_Alloc>::value_compare' : dependent name is not a type
prefix with 'typename' to indicate a type

The code fragment is :-

template<class _K, class _Ty, class _Pr = std::less<_K>,
class _A = std::allocator<_Ty> >
class CVisStlMap {
public:
typedef CVisStlMap<_K, _Ty, _Pr, _A> T_This;
typedef std::map<_K, _Ty, _Pr, _A> T_Map;
typedef std::pair<const _K, _Ty> value_type;

typedef T_Map::_Kfn _Kfn; <---line 163

Where does "typename" go ???

TTFN,
Jon
Nov 17 '05 #1
5 1055
> The code fragment is :-

template<class _K, class _Ty, class _Pr = std::less<_K>,
class _A = std::allocator<_Ty> >
class CVisStlMap {
public:
typedef CVisStlMap<_K, _Ty, _Pr, _A> T_This;
typedef std::map<_K, _Ty, _Pr, _A> T_Map;
typedef std::pair<const _K, _Ty> value_type;

typedef T_Map::_Kfn _Kfn; <---line 163

Where does "typename" go ???


typedef typename T_Map::_Kfn _Kfn;
--
Vladimir Nesterovsky
e-mail: vl******@nesterovsky-bros.com
home: www.nesterovsky-bros.com
Nov 17 '05 #2


"Vladimir Nesterovsky" wrote:
The code fragment is :-

template<class _K, class _Ty, class _Pr = std::less<_K>,
class _A = std::allocator<_Ty> >
class CVisStlMap {
public:
typedef CVisStlMap<_K, _Ty, _Pr, _A> T_This;
typedef std::map<_K, _Ty, _Pr, _A> T_Map;
typedef std::pair<const _K, _Ty> value_type;

typedef T_Map::_Kfn _Kfn; <---line 163

Where does "typename" go ???

typedef typename T_Map::_Kfn _Kfn;


Thats what I initially assumed too. However the compiler generates exactly
the same error :-(

TTFN,
Jon

Nov 17 '05 #3
Jon Evans wrote:
"Vladimir Nesterovsky" wrote:
The code fragment is :-

template<class _K, class _Ty, class _Pr = std::less<_K>,
class _A = std::allocator<_Ty> >
class CVisStlMap {
public:
typedef CVisStlMap<_K, _Ty, _Pr, _A> T_This;
typedef std::map<_K, _Ty, _Pr, _A> T_Map;
typedef std::pair<const _K, _Ty> value_type;

typedef T_Map::_Kfn _Kfn; <---line 163

Where does "typename" go ???

typedef typename T_Map::_Kfn _Kfn;


Thats what I initially assumed too. However the compiler generates
exactly the same error :-(


1. There are probably somewhere betweens tens and hundreds of places that
'typename' needs to be inserted.
2. Are you sure you showed the right code snippet? The error you quoted is
griping about ::value_compare, but there's no reference to ::value_compare
anywhere in the code you posted.
3. Unfortunately, there's no way to force VC7.1 to revert to VC6's bad
habits - this change was mandated by the C++ standard 6 years ago and VC
finally became compliant in this regard with VC7.1.

I just downloaded VisSDK - it was actually just updated in February of this
year, but it still only supports VC6. If you can post a small but complete
example that compiles with VC6 but not with VC7.1 I might be able to figure
out what needs to be fixed up in the VisSDK code.

-cd
Nov 17 '05 #4


"Carl Daniel [VC++ MVP]" wrote:
template<class _K, class _Ty, class _Pr = std::less<_K>,
class _A = std::allocator<_Ty> >
class CVisStlMap {
public:
typedef CVisStlMap<_K, _Ty, _Pr, _A> T_This;
typedef std::map<_K, _Ty, _Pr, _A> T_Map;
typedef std::pair<const _K, _Ty> value_type;

typedef T_Map::_Kfn _Kfn; <---line 163

Where does "typename" go ???
typedef typename T_Map::_Kfn _Kfn;


Thats what I initially assumed too. However the compiler generates
exactly the same error :-(

Hi Carl,
1. There are probably somewhere betweens tens and hundreds of places that
'typename' needs to be inserted.
Absolutely. But at this stage I don't know how many of the errors are caused
by previous errors.

This particular project goes back a few years. The actual image aquisition
side of things have long since been replaced by DirectShow but the project
still uses the image classes from the VisSDK as that would have been a lot of
work to change.
2. Are you sure you showed the right code snippet? The error you quoted is
griping about ::value_compare, but there's no reference to ::value_compare
anywhere in the code you posted.
The text was literally cut and paste.
3. Unfortunately, there's no way to force VC7.1 to revert to VC6's bad
habits -

:-( Shame ; I can understand it from the point of view of Microsoft as they
get plenty of flack when they don't do things the "right" way, but lack of
some mechanism to enable backwards compatability is also a problem.
I just downloaded VisSDK - it was actually just updated in February of this
year, but it still only supports VC6. If you can post a small but complete
example that compiles with VC6 but not with VC7.1 I might be able to figure
out what needs to be fixed up in the VisSDK code.


Create a new VC6 project using the vision app wizard, compile and run it and
alls well, Open the project in dot net and try and compile it.

If I can still use the VisSDK with nothing more than a few extra
"typename"'s or something equally straightfroward then that'd be great.
However it it requires anything more cpomplicated than that then since I'm
only using the basic image class's then I guess it'd be easier just to
replace those.

Thanks,
Jon
Nov 17 '05 #5
Jon Evans wrote:
"Carl Daniel [VC++ MVP]" wrote:
I just downloaded VisSDK - it was actually just updated in February
of this year, but it still only supports VC6. If you can post a
small but complete example that compiles with VC6 but not with VC7.1
I might be able to figure out what needs to be fixed up in the
VisSDK code.
Create a new VC6 project using the vision app wizard, compile and run
it and alls well, Open the project in dot net and try and compile it.


Unfortunately, I don't have VC6 loaded anymore - haven't used it for years.
If I can still use the VisSDK with nothing more than a few extra
"typename"'s or something equally straightfroward then that'd be
great. However it it requires anything more cpomplicated than that
then since I'm only using the basic image class's then I guess it'd
be easier just to replace those.


That could well be the case.

-cd
Nov 17 '05 #6

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

Similar topics

1
by: Vince C. | last post by:
Hi all, I've created XML documents that are described with a schema. I'm using those documents to create web pages. All my web pages contain a fixed header and a variable document part. The...
5
by: Tom Alsberg | last post by:
Hi there... I'm recently trying to get a bit acquainted with XML Schemas and XSL. Now, I have a few questions about XSL stylesheets and templates: * Is there a way to "enter" a child element...
22
by: E. Robert Tisdale | last post by:
According to the C++ FAQ Lite: http://www.parashift.com/ What is "genericity"? Yet another way to say, "class templates." Not to be confused with "generality" (which just means avoiding...
12
by: Fabio De Francesco | last post by:
Hello. I can't understand why I can't compile the following simple code, where I think I have applied all the needed rules for templates that are declared and defined in different files (*.h and...
16
by: WittyGuy | last post by:
Hi, What is the major difference between function overloading and function templates? Thanks! http://www.gotw.ca/resources/clcm.htm for info about ]
2
by: jimbo_vr5 | last post by:
Hey I think i've figured out the idea behind apply-templates. But going through the tutorial on <http://www.w3schools.com/xsl/xsl_apply_templates.asp> theres simply just something that i dont...
25
by: Ted | last post by:
I'm putting the posts that follow here (hopefully they will follow here!) because they were rejected in comp.lang.c++.moderated. It behooves anyone reading them to first read the the thread of the...
28
by: NewToCPP | last post by:
Hi, I am just trying to find out if there is any strong reason for not using Templates. When we use Templates it is going to replicate the code for different data types, thus increasing the...
104
by: JohnQ | last post by:
Well apparently not since one can step thru template code with a debugger. But if I was willing to make the concession on debugging, templates would be strictly a precompiler thing? I have a...
7
by: Chris | last post by:
Hi All, This is a weird one but I am hoping someone can help or has some pointers, a recipe how to do the following: I have to move some code from c++ to objective-c and to do this I must...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.