mirror of
https://github.com/dlang/phobos.git
synced 2025-05-06 11:07:39 +03:00
Improve std.conv.parse
support for scope
strings
This commit is contained in:
parent
5f505267fa
commit
6ceeb18c82
1 changed files with 6 additions and 7 deletions
13
std/conv.d
13
std/conv.d
|
@ -2850,7 +2850,7 @@ do
|
||||||
static if (isNarrowString!Source)
|
static if (isNarrowString!Source)
|
||||||
{
|
{
|
||||||
import std.string : representation;
|
import std.string : representation;
|
||||||
auto s = source.representation;
|
scope s = source.representation;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2898,7 +2898,7 @@ do
|
||||||
}
|
}
|
||||||
|
|
||||||
static if (isNarrowString!Source)
|
static if (isNarrowString!Source)
|
||||||
source = cast(Source) s;
|
source = source[$ - s.length .. $];
|
||||||
|
|
||||||
static if (doCount)
|
static if (doCount)
|
||||||
{
|
{
|
||||||
|
@ -3105,7 +3105,7 @@ if (isSomeString!Source && !is(Source == enum) &&
|
||||||
* A $(LREF ConvException) if `source` is empty, if no number could be
|
* A $(LREF ConvException) if `source` is empty, if no number could be
|
||||||
* parsed, or if an overflow occurred.
|
* parsed, or if an overflow occurred.
|
||||||
*/
|
*/
|
||||||
auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref scope Source source)
|
auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source source)
|
||||||
if (isInputRange!Source && isSomeChar!(ElementType!Source) && !is(Source == enum) &&
|
if (isInputRange!Source && isSomeChar!(ElementType!Source) && !is(Source == enum) &&
|
||||||
isFloatingPoint!Target && !is(Target == enum))
|
isFloatingPoint!Target && !is(Target == enum))
|
||||||
{
|
{
|
||||||
|
@ -3115,18 +3115,17 @@ if (isInputRange!Source && isSomeChar!(ElementType!Source) && !is(Source == enum
|
||||||
static if (isNarrowString!Source)
|
static if (isNarrowString!Source)
|
||||||
{
|
{
|
||||||
import std.string : representation;
|
import std.string : representation;
|
||||||
auto p = source.representation;
|
scope p = source.representation;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
alias p = source;
|
alias p = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
void advanceSource() @trusted
|
void advanceSource()
|
||||||
{
|
{
|
||||||
// p is assigned from source.representation above so the cast is valid
|
|
||||||
static if (isNarrowString!Source)
|
static if (isNarrowString!Source)
|
||||||
source = cast(Source) p;
|
source = source[$ - p.length .. $];
|
||||||
}
|
}
|
||||||
|
|
||||||
static immutable real[14] negtab =
|
static immutable real[14] negtab =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue