std.conv.parse for user defined structs/objects

H. S. Teoh hsteoh at quickfur.ath.cx
Sun Jan 5 20:19:31 PST 2014


On Fri, Dec 27, 2013 at 08:43:25PM +0000, Ilya Yaroshenko wrote:
> 
> >I've been thinking about this too. It shouldn't be too hard to add
> >this to std.conv (I'd call it "fromString", though, by analogy with
> >"toString" -- "parseImpl" looks a bit ugly).
> 
> Is "fromString" good in case of InputRange?

Good point. Maybe "parse"?

	class T {
		static T parse(R)(R inputRange)
			if (is(ElementType!R : dchar))
		{
			T result;
			... // parse inputRange
			return result;
		}
	}


T

-- 
To err is human; to forgive is not our policy. -- Samuel Adler


More information about the Digitalmars-d mailing list