digitalmars.D.bugs - template instance vec!(1) vec is not a template declaration
- hellcatv hotmail.com May 06 2004
- "Ivan Senji" <ivan.senji public.srce.hr> May 06 2004
- hellcatv hotmail.com May 06 2004
It is critical to be able to instantiate a class with different template
argumetns to be able to do a cast function (i.e. a double vector to a single
vector) or in this case to be able to make a smaller vector from a bigger one.
Doing this with static functions outside the class is painful and the syntax is
clunky (no operators, no implicit members that actually call get/set functions).
test program that fails:
struct vec(int size) {
float v[size];
vec!(1) first() {vec!(1) t; t.v[0]=v[0];return t;}
}
int main () {
vec!(2) v;
vec!(1) g =v.first();
}
May 06 2004
<hellcatv hotmail.com> wrote in message news:c7ctkt$1all$1 digitaldaemon.com...It is critical to be able to instantiate a class with different template argumetns to be able to do a cast function (i.e. a double vector to a
vector) or in this case to be able to make a smaller vector from a bigger
Doing this with static functions outside the class is painful and the
clunky (no operators, no implicit members that actually call get/set
test program that fails: struct vec(int size) { float v[size]; vec!(1) first() {vec!(1) t; t.v[0]=v[0];return t;} } int main () { vec!(2) v; vec!(1) g =v.first(); }
There is no bug here, you missed something that isn't documented (at least i didn't find it) It should be: struct vec(int size) { float v[size]; .vec!(1) first() {.vec!(1) t; t.v[0]=v[0];return t;} } int main () { vec!(2) v; vec!(1) g =v.first(); return 1; } template vec belongs to global scope so . gives acces to global scope.
May 06 2004
D is my new favorite language :-) thanks In article <c7d1kc$1gr1$1 digitaldaemon.com>, Ivan Senji says...<hellcatv hotmail.com> wrote in message news:c7ctkt$1all$1 digitaldaemon.com...It is critical to be able to instantiate a class with different template argumetns to be able to do a cast function (i.e. a double vector to a
vector) or in this case to be able to make a smaller vector from a bigger
Doing this with static functions outside the class is painful and the
clunky (no operators, no implicit members that actually call get/set
test program that fails: struct vec(int size) { float v[size]; vec!(1) first() {vec!(1) t; t.v[0]=v[0];return t;} } int main () { vec!(2) v; vec!(1) g =v.first(); }
There is no bug here, you missed something that isn't documented (at least i didn't find it) It should be: struct vec(int size) { float v[size]; .vec!(1) first() {.vec!(1) t; t.v[0]=v[0];return t;} } int main () { vec!(2) v; vec!(1) g =v.first(); return 1; } template vec belongs to global scope so . gives acces to global scope.
May 06 2004








hellcatv hotmail.com