Zig vs D generics

Quirin Schroll qs.il.paperinik at gmail.com
Mon Oct 10 16:59:56 UTC 2022


On Monday, 10 October 2022 at 14:18:52 UTC, Paulo Pinto wrote:
> I guess you did something wrong, :)
> ```cpp
> #include <string>
> #include <iostream>
>
> constexpr std::string hello() {
>     return std::string("hello world");
> }
>
> int main() {
>     static constexpr auto greeting = hello();
>
>     std::cout << greeting << std::endl;
> }
> ```

This only works because you initialize the `std::string` with a 
literal. It fails on this:
```cpp
      return std::string("hello ") + "world";
```


More information about the Digitalmars-d mailing list