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 = literal.split(',').array;
---
That split won't work if you have something more complicated,
like struct values:
struct Foo
{
int a;
int b;
}
enum literal = ["one":Foo(1, 2), "two":Foo(3,
4)].stringof[1..$-1];
enum pairs = literal.split(',').array;
static assert(pairs == 4);
--
/Jacob Carlborg