Re: Need template work-around in VC6
- From: "Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@xxxxxxxxxxxxxxx>
- Date: Wed, 23 Aug 2006 16:41:09 -0700
"mlimber" <mlimber@xxxxxxxxx> wrote in message
news:1156357989.032727.206660@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I am using VC++ 6 (sp6) and cannot change compilers. I have something
akin to this code:
#include <iostream>
using namespace std;
template<int i>
struct Int2Type
{
enum { value = i };
};
struct Foo
{
template<int i>
void Bar()
{
cout << i << endl;
}
// Ugly work-around
template<int i>
void Baz( const Int2Type<i>& )
{
cout << i << endl;
}
};
int main()
{
Foo f;
f.Bar<42>(); // Error here
f.Baz( Int2Type<42>() );
return 0;
}
The error message is: "error C2059: syntax error : ')'". I can use the
ugly work-around with Int2Type that is shown, but I would much prefer
something simpler and more aesthetically pleasing. Any ideas?
For VC6? No, not really (not that I've seen anyway). The parser simply
doesn't understand explicit template arguments on a function invocation.
-cd
.
- Follow-Ups:
- Re: Need template work-around in VC6
- From: mlimber
- Re: Need template work-around in VC6
- References:
- Need template work-around in VC6
- From: mlimber
- Need template work-around in VC6
- Prev by Date: Re: How to write a managed wrapper class for a unmanaged Dialog class in VC++?
- Next by Date: Re: Need template work-around in VC6
- Previous by thread: Need template work-around in VC6
- Next by thread: Re: Need template work-around in VC6
- Index(es):
Relevant Pages
|