Failure due to memcpy being called at compile time
Steven Schveighoffer
schveiguy at gmail.com
Mon Jun 13 20:25:00 UTC 2022
On 6/13/22 4:09 PM, JG wrote:
> Thanks. It seems to be something to do with the variadic template since
> this
> works:
>
> ```d
> import std;
>
> struct ParseError { string msg; }
>
> alias ParseErrorOr(T) = SumType!(ParseError,T);
> auto parseErrorOr(T)(T x) { return ParseErrorOr!T(x); }
>
> auto parserOr(I,alias f, alias g)(I i) {
> auto cur = f(i);
> if(cur.match!((ParseError e)=>false,_=>true)) { return cur; }
> return g(i);
> }
>
> auto parseNothing(I)(I i) {
> return parseErrorOr(tuple(i[0..0],i));
> }
>
> void main()
> {
> enum a =
> parserOr!(string,parseNothing!string,parseNothing!string)("hello");
> }
> ```
Given that it's inside `moveEmplace`, I'd suspect something deep in
`SumType`.
-Steve
More information about the Digitalmars-d-learn
mailing list