fromString

Performs nothrow and @nogc string to native type conversion.

Rseturns: true if success and false otherwise.

  1. template fromString(T)
  2. bool fromString(const(C)[] str, T value)
    @trusted
    bool
    fromString
    (
    T
    C
    )
    (
    scope const(C)[] str
    ,
    ref T value
    )
    if (
    isSomeChar!C &&
    isFloatingPoint!T
    )
  3. bool fromString(const(C)[] str, T value)

Examples

int value;
assert("123".fromString(value) && value == 123);
double value = 0;
assert("+Inf".fromString(value) && value == double.infinity);
assert("-nan".fromString(value) && value != value);