Pattern matching in C++ and D

IGotD- nise at nise.com
Tue Jan 7 17:06:30 UTC 2020


On Tuesday, 7 January 2020 at 14:00:01 UTC, Francesco Mecca wrote:
> I found a paper regarding a proposal for pattern matching in 
> C++ on HN a few days ago:
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1371r1.pdf
>
> ```
> let function_with_side_effects x = ...
> let match x = match x with
>     | p1 -> e1
>     | p2 when function_with_side_effects x -> e2
>     | _ -> e3
> ```

Doesn't the real benefit first kick in when the statement is an 
expression always returning a value like in your example?

Neither C++ or D has that.


More information about the Digitalmars-d mailing list