August 10, 2003 instrinsic | ||||
---|---|---|---|---|
| ||||
In Phobos there is a part called instrinsic. There are some functions like sin, cos, ... that are as well in math, but here are some instrinic versions. shouldn't the versions in math be instrinsic if possible and not be part of the instrinisc-library? |
August 10, 2003 Re: instrinsic | ||||
---|---|---|---|---|
| ||||
Posted in reply to Helium | Helium <Helium_member@pathlink.com> wrote in news:bh5770$188c$1@digitaldaemon.com: > Sorry, I just like 'em. Regardless of how awkward and broken in C++, they rule. Great, if you like templates beeing awkward and broken in C++, then you'll like them even more in D. Since they are even more awkward and broken ;-) > > template A(T) { > void func(T *a) { } > } > > class B { > static void func(int *a) { } > } > > template C(T, FuncType) { > void doIt(T *a) { FuncType.func(a); } > } > > int main(char[][] args) { > int x; > > instance C(int, B) doer; // this works > doer.doIt(&x); > > instance C(int, instance A(int)) doer2; // this does not > doer2.doIt(); > > return x; > } > > Why can't a template instance be treated as a type? Seems to be a hole in the language or a compiler bug. But I think it's a confusing feature, anyway. Initially when I saw template C(T, FuncType) { void doIt(T *a) { FuncType.func(a); } I thought FuncType must be a class or a struct type with a static member function. I didn't expect that FuncType could also be a template declaration. How wrong I was - how confused I am now. |
Copyright © 1999-2021 by the D Language Foundation