BigUIntView.fromHexStringImpl

struct BigUIntView(W, WordEndian endian = TargetEndian)
@safe pure @nogc nothrow scope
static if(isMutable!W)
bool
fromHexStringImpl
(
C
bool allowUnderscores = false
)
(
scope const(C)[] str
)
if (
isSomeChar!C
)
if (
__traits(isUnsigned, W)
)

Examples

auto view = BigUIntView!size_t.fromHexString!(char, true)("abcd_efab_cdef");
assert(cast(ulong)view == 0xabcd_efab_cdef);
// Check that invalid underscores in hex literals throw an error.
void expectThrow(const(char)[] input) {
    bool caught = false;
    try { 
        auto view = BigUIntView!size_t.fromHexString!(char, true)(input);
    } catch (Exception e) {
        caught = true;
    }

    assert(caught);
}

expectThrow("abcd_efab_cef_");
expectThrow("abcd__efab__cef");
expectThrow("_abcd_efab_cdef");
expectThrow("_abcd_efab_cdef_");
expectThrow("_abcd_efab_cdef__");
expectThrow("__abcd_efab_cdef");
expectThrow("__abcd_efab_cdef_");
expectThrow("__abcd_efab_cdef__");
expectThrow("__abcd__efab_cdef__");
expectThrow("__abcd__efab__cdef__");

Meta