D - [Bug] struct template type error
- Patrick Down (18/18) Jan 14 2004 The following code snippit generated this error:
- C (41/58) Jan 14 2004 struct Foo(T)
- C (5/68) Jan 14 2004 Chaing bar to be a non-static method T is still an undefined identifier ...
- Patrick Down (7/87) Jan 14 2004 Yeah I had the same problem.
- Patrick Down (20/100) Jan 14 2004 This give me the error:
The following code snippit generated this error:
err.d(9): Foo is used as a type
struct Foo(T)
{
T x = 0;
static Foo bar(T c1)
{
Foo rtn; // Error here
rtn.x = c1;
return rtn;
}
}
void func()
{
alias Foo!(double) vector;
vector xAxis = vector.bar(1);
}
Jan 14 2004
struct Foo(T)
{
T x = 0;
static Foo bar(T c1)
{
Foo !(double) rtn; // must instantiate with type
rtn.x = c1;
return rtn;
}
}
void func()
{
alias Foo!(double) vector;
vector xAxis = vector.bar(1);
}
Howerver if use T to instatiate Foo , I get
identifier 'T' is not defined
Changing the code to
==============
struct Foo(T)
{
T x = 0;
static Foo bar(T c1)
{
Foo !(typeof(c1) ) rtn; // must instantiate with type
rtn.x = c1;
return rtn;
}
}
void func()
{
alias Foo!(double) vector;
vector xAxis = vector.bar(1);
}
void main () { func(); }
Works and is probably what you want ?
C
C
void main () { func(); }
"Patrick Down" <pat codemoon.com> wrote in message
news:Xns9470D8C2F1A87patcodemooncom 63.105.9.61...
The following code snippit generated this error:
err.d(9): Foo is used as a type
struct Foo(T)
{
T x = 0;
static Foo bar(T c1)
{
Foo rtn; // Error here
rtn.x = c1;
return rtn;
}
}
void func()
{
alias Foo!(double) vector;
vector xAxis = vector.bar(1);
}
Jan 14 2004
Chaing bar to be a non-static method T is still an undefined identifier ,
why is that ?
C
"C" <dont respond.com> wrote in message
news:bu51u2$boo$1 digitaldaemon.com...
struct Foo(T)
{
T x = 0;
static Foo bar(T c1)
{
Foo !(double) rtn; // must instantiate with type
rtn.x = c1;
return rtn;
}
}
void func()
{
alias Foo!(double) vector;
vector xAxis = vector.bar(1);
}
Howerver if use T to instatiate Foo , I get
identifier 'T' is not defined
Changing the code to
==============
struct Foo(T)
{
T x = 0;
static Foo bar(T c1)
{
Foo !(typeof(c1) ) rtn; // must instantiate with type
rtn.x = c1;
return rtn;
}
}
void func()
{
alias Foo!(double) vector;
vector xAxis = vector.bar(1);
}
void main () { func(); }
Works and is probably what you want ?
C
C
void main () { func(); }
"Patrick Down" <pat codemoon.com> wrote in message
news:Xns9470D8C2F1A87patcodemooncom 63.105.9.61...
The following code snippit generated this error:
err.d(9): Foo is used as a type
struct Foo(T)
{
T x = 0;
static Foo bar(T c1)
{
Foo rtn; // Error here
rtn.x = c1;
return rtn;
}
}
void func()
{
alias Foo!(double) vector;
vector xAxis = vector.bar(1);
}
Jan 14 2004
inline "C" <dont respond.com> wrote in news:bu51u2$boo$1 digitaldaemon.com:struct Foo(T) { T x = 0; static Foo bar(T c1) { Foo !(double) rtn; // must instantiate with type rtn.x = c1; return rtn; } } void func() { alias Foo!(double) vector; vector xAxis = vector.bar(1); } Howerver if use T to instatiate Foo , I get identifier 'T' is not definedYeah I had the same problem. Foo!(T) rtn; should work. I think this is the real bug.Changing the code to ============== struct Foo(T) { T x = 0; static Foo bar(T c1) { Foo !(typeof(c1) ) rtn; // must instantiate with type rtn.x = c1; return rtn; } } void func() { alias Foo!(double) vector; vector xAxis = vector.bar(1); } void main () { func(); } Works and is probably what you want ? CYes that works, Thanks.C void main () { func(); } "Patrick Down" <pat codemoon.com> wrote in message news:Xns9470D8C2F1A87patcodemooncom 63.105.9.61...The following code snippit generated this error: err.d(9): Foo is used as a type struct Foo(T) { T x = 0; static Foo bar(T c1) { Foo rtn; // Error here rtn.x = c1; return rtn; } } void func() { alias Foo!(double) vector; vector xAxis = vector.bar(1); }
Jan 14 2004
This give me the error:
template instance Foo!(double) Foo is not a template declaration
struct Foo(T)
{
T x = 0;
static Foo!(T) bar(T c1)
{
Foo!(typeof(c1)) rtn;
rtn.x = c1;
return rtn;
}
}
void func()
{
alias Foo!(double) vector;
vector xAxis = vector.bar(1);
}
void main () { func(); }
"C" <dont respond.com> wrote in news:bu51u2$boo$1 digitaldaemon.com:
struct Foo(T)
{
T x = 0;
static Foo bar(T c1)
{
Foo !(double) rtn; // must instantiate with type
rtn.x = c1;
return rtn;
}
}
void func()
{
alias Foo!(double) vector;
vector xAxis = vector.bar(1);
}
Howerver if use T to instatiate Foo , I get
identifier 'T' is not defined
Changing the code to
==============
struct Foo(T)
{
T x = 0;
static Foo bar(T c1)
{
Foo !(typeof(c1) ) rtn; // must instantiate with type
rtn.x = c1;
return rtn;
}
}
void func()
{
alias Foo!(double) vector;
vector xAxis = vector.bar(1);
}
void main () { func(); }
Works and is probably what you want ?
C
C
void main () { func(); }
"Patrick Down" <pat codemoon.com> wrote in message
news:Xns9470D8C2F1A87patcodemooncom 63.105.9.61...
The following code snippit generated this error:
err.d(9): Foo is used as a type
struct Foo(T)
{
T x = 0;
static Foo bar(T c1)
{
Foo rtn; // Error here
rtn.x = c1;
return rtn;
}
}
void func()
{
alias Foo!(double) vector;
vector xAxis = vector.bar(1);
}
Jan 14 2004









"C" <dont respond.com> 