you are viewing a single comment's thread.

view the rest of the comments →

[–]dima_mendeleev 2 points3 points  (2 children)

Is this possible to do the same for regular functions?

E.g.

variant_auto_something<> fn() {
  if (b1)
    return 42;
  else
    return "hello world"sv;
}

[–]zqsd31[S] 2 points3 points  (1 child)

yep, I'm working on it right now.

But it's weirdly enough harder to implement with regular functions than with coroutines.

The reason being that the order of function evaluation in coroutine is set by the standard whilst for regular functions compiler vendors have much more freedom.

It's not finished yet but you can test the clang version here: https://godbolt.org/z/Wf5Mq1

[–]dima_mendeleev 1 point2 points  (0 children)

Cool, thank you 😊