On Tuesday, 7 July 2020 at 12:41:23 UTC, Per Nordlöw wrote:
What about construction and assignment from a static array of
`Pair`'s? Wouldn't that be easier on the compiler?
I you refer to it wouldn't be using templates, then yes, I guess
so.
--
/Jacob Carlborg
On Monday, 6 July 2020 at 12:04:11 UTC, Jacob Carlborg wrote:
void main() @nogc
{
auto a = tuple(Pair("foo", 1), Pair("bar", 2));
}
--
/Jacob Carlborg
Thanks.
What about construction and assignment from a static array of
`Pair`'s? Wouldn't that be easier on the compiler?
On Sunday, 5 July 2020 at 21:06:32 UTC, Per Nordlöw wrote:
Is there a way to construct a custom written hash-table
container (struct) from an AA-literal expression?
I think your best bet is a tuple of pairs, because then you're
not limited to compile time values, but it won't look pretty:
On Monday, 6 July 2020 at 01:43:43 UTC, user1234 wrote:
---
import std;
struct AA
{
void opIndexAssign(int v, string k) @nogc
{}
}
void main(string[] args) @nogc
{
AA myCustom;
enum literal = ["one":1, "two":2].stringof[1..$-1];
enum pairs = literal.split(',').array;
On Monday, 6 July 2020 at 11:51:19 UTC, Jacob Carlborg wrote:
On Monday, 6 July 2020 at 01:43:43 UTC, user1234 wrote:
Hereh we go ;)
---
import std;
struct AA
{
void opIndexAssign(int v, string k) @nogc
{}
}
void main(string[] args) @nogc
{
AA myCustom;
enum literal =
On Monday, 6 July 2020 at 01:43:43 UTC, user1234 wrote:
Hereh we go ;)
---
import std;
struct AA
{
void opIndexAssign(int v, string k) @nogc
{}
}
void main(string[] args) @nogc
{
AA myCustom;
enum literal = ["one":1, "two":2].stringof[1..$-1];
enum pairs =
On Sunday, 5 July 2020 at 21:38:12 UTC, Per Nordlöw wrote:
On Sunday, 5 July 2020 at 21:22:13 UTC, ikod wrote:
struct AA(K,V)
{
void opAssign(V[K] aa)
{
}
}
void main()
{
AA!(string, int) custom_aa;
custom_aa = ["one":1, "two":2];
}
Forget to mention that I want the
On Sunday, 5 July 2020 at 21:06:32 UTC, Per Nordlöw wrote:
Is there a way to construct a custom written hash-table
container (struct) from an AA-literal expression?
How about iterating the literal, e.g
---
foreach (k,v; ["one":1, "two":2])
{
myCustomAA[k] = v;
}
---
On Sunday, 5 July 2020 at 21:22:13 UTC, ikod wrote:
struct AA(K,V)
{
void opAssign(V[K] aa)
{
}
}
void main()
{
AA!(string, int) custom_aa;
custom_aa = ["one":1, "two":2];
}
Forget to mention that I want the assign call (to `opAssign`) in
`main` to be non-(GC)heap
On Sunday, 5 July 2020 at 21:06:32 UTC, Per Nordlöw wrote:
Is there a way to construct a custom written hash-table
container (struct) from an AA-literal expression?
can opAssign help?
struct AA(K,V)
{
void opAssign(V[K] aa)
{
}
}
void main()
{
AA!(string, int) custom_aa;
Is there a way to construct a custom written hash-table container
(struct) from an AA-literal expression?
11 matches
Mail list logo