std.conv.parse for user defined structs/objects

Dmitry Olshansky dmitry.olsh at gmail.com
Mon Jan 6 02:28:38 PST 2014


06-Jan-2014 08:19, H. S. Teoh пишет:
> 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"?
>

Parse from an input range... That's going to be tricky and inefficient.

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


-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list