Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / October 2004

Tip: Looking for answers? Try searching our database.

Templates in .NET

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jon Evans - 21 Oct 2004 11:25 GMT
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
Vladimir Nesterovsky - 21 Oct 2004 11:51 GMT
> The code fragment is :-
>
[quoted text clipped - 9 lines]
>
> Where does "typename" go ???

typedef typename T_Map::_Kfn _Kfn;
Signature

Vladimir Nesterovsky
e-mail: vladimir@nesterovsky-bros.com
home: www.nesterovsky-bros.com

Jon Evans - 21 Oct 2004 13:19 GMT
> > The code fragment is :-
> >
[quoted text clipped - 9 lines]
> >
> > 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
Carl Daniel [VC++ MVP] - 21 Oct 2004 14:33 GMT
>>> The code fragment is :-
>>>
[quoted text clipped - 14 lines]
> 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
Jon Evans - 22 Oct 2004 10:31 GMT
> >>> template<class _K, class _Ty, class _Pr = std::less<_K>,
> >>> class _A = std::allocator<_Ty> >
[quoted text clipped - 12 lines]
> > 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
Carl Daniel [VC++ MVP] - 22 Oct 2004 14:34 GMT
>> 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
[quoted text clipped - 4 lines]
> 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
James Curran - 26 Oct 2004 22:57 GMT
> 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.

   In vc7.1, in the map template definition in the include file <map>,
there is the definition:

typedef typename _Mybase::value_compare value_compare;

I wonder if in vc7.0 the "typename" was left off that typedef.....

Signature

Truth,
James Curran
[erstwhile VC++ MVP]
Home: www.noveltheory.com       Work: www.njtheater.com
Blog: www.honestillusion.com  Day Job: www.partsearch.com


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.