On 11/3/14 9:07 AM, Uranuz wrote:
I have an example of code like this:
template Node(String)
{
struct Node {}
struct Name {}
struct Attr {}
}
void main()
{
alias MyNode = Node!(string).Node;
alias MyName = Node!(string).Name;
alias MyAttr = Node!(string).Attr;
}
On Monday, 3 November 2014 at 14:58:03 UTC, Ali Çehreli wrote:
I think it's the intended behavior. I think documentation is
outdated.
Both forms should really work though. I had always thought that
the short form was simply possible if the names matched.
Also I failed to find any documentation about eponymous stuff in
language reference. As far as I remember it was here but now
looks like it is missing.
I think it's the intended behavior. I think documentation is
outdated.
Ali
Thanks. So I will modify my programme to workaround this.
On 11/03/2014 06:36 AM, Uranuz wrote:
Looks like compiler looks for Node, Name and Attr in Node struct,
because of eponymous thing.
I understand it but I want to know if it is documented behaviour or not.
Could anybody clear what happens with eponymous stuff and why I can't
get acces to *other*
Looks like compiler looks for Node, Name and Attr in Node
struct, because of eponymous thing.
I understand it but I want to know if it is documented behaviour
or not. Could anybody clear what happens with eponymous stuff and
why I can't get acces to *other* declarations inside eponymous
templ
On Monday, 3 November 2014 at 14:07:55 UTC, Uranuz wrote:
I have an example of code like this:
template Node(String)
{
struct Node {}
struct Name {}
struct Attr {}
}
void main()
{
alias MyNode = Node!(string).Node;
alias MyName = Node!(string).Na
I have an example of code like this:
template Node(String)
{
struct Node {}
struct Name {}
struct Attr {}
}
void main()
{
alias MyNode = Node!(string).Node;
alias MyName = Node!(string).Name;
alias MyAttr = Node!(string).Attr;
}
On 06/12/2013 02:56 PM, matovitch wrote:
On Wednesday, 12 June 2013 at 21:52:46 UTC, Ali Çehreli wrote:
Here is one way:
void func(V, alias def_val) (uint i, V v)
if (is (typeof(def_val == V.type)))
Oops. It should be:
if (is (typeof(def_val) == V.type))
Hmmm. How come the other on
matovitch:
void func(V, V.type def_val) (uint i, V v)
{
if (i < v.dimension) {
v.data[i] = def_val;
}
}
I think something like that is not yet possible, but maybe it
will be possible later.
Your code has also allowed me to find a new small compiler bug
that
On Wednesday, 12 June 2013 at 21:52:46 UTC, Ali Çehreli wrote:
Here is one way:
void func(V, alias def_val) (uint i, V v)
if (is (typeof(def_val == V.type)))
{
if (i < v.dimension) {
v.data[i] = def_val;
}
}
Ali
Thank you !
On 06/12/2013 02:47 PM, matovitch wrote:
To be more precise the code below doesn't compile :
struct Vector(T, uint N)
{
alias T type;
enum dimension = N;
T data[N];
}
void func(V, V.type def_val) (uint i, V v)
{
if (i < v.dimension) {
v.data[i] = def_val;
}
}
To be more precise the code below doesn't compile :
struct Vector(T, uint N)
{
alias T type;
enum dimension = N;
T data[N];
}
void func(V, V.type def_val) (uint i, V v)
{
if (i < v.dimension) {
v.data[i] = def_val;
}
}
void main()
{
On 06/12/2013 02:26 PM, matovitch wrote:> Hello,
>
> I got a simple vector template :
>
> struct Vector(T, uint N)
> {
>alias type T;
You later corrected that it should be
alias T type;
But still, prefer the new syntax over the backward C syntax:
alias type = T;
>T data[N]
On Wednesday, 12 June 2013 at 21:36:38 UTC, H. S. Teoh wrote:
On Wed, Jun 12, 2013 at 11:26:40PM +0200, matovitch wrote:
Hello,
I got a simple vector template :
struct Vector(T, uint N)
{
alias type T;
[...]
This line should read:
alias type = T;
And it should work as you wan
On Wed, Jun 12, 2013 at 11:26:40PM +0200, matovitch wrote:
> Hello,
>
> I got a simple vector template :
>
> struct Vector(T, uint N)
> {
> alias type T;
[...]
This line should read:
alias type = T;
And it should work as you wanted.
T
--
If you look at a thing nine hundred an
Hello,
I got a simple vector template :
struct Vector(T, uint N)
{
alias type T;
T data[N];
}
And I'd like to call a function like :
void func(V, V.type default_value)(args...);
But this (of course) doesn't work. Is there a simple and nice way
to do this ? (I'm sure there is ;-))
17 matches
Mail list logo