Thread overview
[Issue 21456] std.format does not accept enum member with string base type as template parameter
May 02
Dlang Bot
May 04
Dlang Bot
1 day ago
Dlang Bot
1 day ago
Berni44
May 02
https://issues.dlang.org/show_bug.cgi?id=21456

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #1 from Dlang Bot <dlang-bot@dlang.rocks> ---
@berni44 created dlang/phobos pull request #8029 "Fix Issue 21456 - std.format does not accept enum member with string base type as template parameter" fixing this issue:

- Fix Issue 21456 - std.format does not accept enum member with string base type as template parameter

https://github.com/dlang/phobos/pull/8029

--
May 04
https://issues.dlang.org/show_bug.cgi?id=21456

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #2 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/phobos pull request #8029 "Fix Issue 21456 - std.format does not accept enum member with string base type as template parameter" was merged into master:

- 9d71253c561727a7793bc70cdb353795fa448007 by berni44:
  Fix Issue 21456 - std.format does not accept enum member with string base
type as template parameter

https://github.com/dlang/phobos/pull/8029

--
1 day ago
https://issues.dlang.org/show_bug.cgi?id=21456

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/phobos pull request #8057 "Revert "Fix Issue 21456 - std.format does not accept enum member with string base type as template parameter"" was merged into master:

- 4a9a203087ef84df79014682aaa91e814b3224ee by berni44:
  Revert "Fix Issue 21456 - std.format does not accept enum member with string
base type as template parameter"

  This reverts commit 974a88a967e2e4c6495bd469d3237a4f5aa8b4ab.

https://github.com/dlang/phobos/pull/8057

--
1 day ago
https://issues.dlang.org/show_bug.cgi?id=21456

Berni44 <bugzilla@bernis-buecher.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@bernis-buecher.de
         Resolution|FIXED                       |INVALID

--- Comment #4 from Berni44 <bugzilla@bernis-buecher.de> ---
As can be read in the discussions of the PRs, this has been seen as invalid, because it causes too much problems to accept such enums as strings, while there is only little use. It was suggested to use FMTS.ONE.representation instead, but that doesn't work, because the representation is immutable(ubyte)[] and not string.

Anyway, a working workaround is

enum FMTS : string
{
    ONE = "%s is %s"
}
immutable string fmt = FMTS.ONE;
assert (format!fmt("Pi", 3.14) == "Pi is 3.14");

--