Issue 10061 - formattedRead should be more generic and accept output ranges
Summary: formattedRead should be more generic and accept output ranges
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-10 13:48 UTC by Martin Nowak
Modified: 2024-12-01 16:17 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Martin Nowak 2013-05-10 13:48:42 UTC
import std.format, std.range;

void main()
{
  string line = "12 13 14";

  // arrays work
  int[] ary;
  formattedRead(line, "%(%d %)", &ary);
  assert(ary == [12, 13, 14]);

  // output ranges
  auto app = appender!(int[])();
  formattedRead(line, "%(%d %)", &app);
  assert(app.data == [12, 13, 14]);

  // delegates
  int cnt = 12;
  auto dg = (int v) { assert(v == cnt++); };
  formattedRead(line, "%(%d %)", dg);
}
Comment 1 dlangBugzillaToGithub 2024-12-01 16:17:35 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/9974

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB