Re: EVC++: compile errors disappear when preprocessor output is on
- From: "Mark.Stijnman@xxxxxxxxx" <Mark.Stijnman@xxxxxxxxx>
- Date: 10 Jul 2006 03:49:58 -0700
Just figured I'd give a little update. So, the fact that the
preprocessor output made the errors disappear is due to my own
sillyness for confusing /P and /E. The problem still remained that the
compiler gives a lot of syntax errors when I used my new template class
as a member variable of an existing class, while it worked fine in the
unit test. So, temporarily, I removed the template class, and replaced
it with a new, much simpler class to at least make progress. At some
point, I decided I needed a templated constructor for that one though,
so I could initialize the member using different enum types, in this
case (don't ask). So I introduced something along the lines of:
class MyClass
{
public:
MyClass(const int i): m_i(i) {}
template <typename T>
MyClass(const T t): m_i(static_cast<int>(t)) {}
private:
int m_i;
};
and presto! I got heaploads of syntax errors again. Just on a hunch, I
changed the line
MyClass(const T t)
to
MyClass(const T& t)
and it worked again, no more compile errors! I have no idea why one
works and the other doesn't, but that's how it seems to be.
Turned out that the previous, more elaborate template class also had a
constructor of this form. Changing its argument to a reference to T
also solved that one's compile errors when I used it as a member
variable. So I now know what is causing those mysterious compile
errors, I just still don't know why. I guess it's just this compiler's
bad support for templates, or something. Anyone know why
const-reference-to-T works and const-T-by-value doesn't? Is this a
known rule of thumb to get EVC++/VC6 to use templated constructors
properly?
.
- Follow-Ups:
- Re: EVC++: compile errors disappear when preprocessor output is on
- From: Alex Blekhman
- Re: EVC++: compile errors disappear when preprocessor output is on
- References:
- EVC++: compile errors disappear when preprocessor output is on
- From: Mark.Stijnman@xxxxxxxxx
- EVC++: compile errors disappear when preprocessor output is on
- Prev by Date: "Pretty" lexical_cast
- Next by Date: Re: "Pretty" lexical_cast
- Previous by thread: Re: EVC++: compile errors disappear when preprocessor output is on
- Next by thread: Re: EVC++: compile errors disappear when preprocessor output is on
- Index(es):
Relevant Pages
|