View source code
Display the source code in std/experimental/checkedint.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

std.experimental.checkedint.Checked.this - multiple declarations

Function Checked.this

Constructor taking a value properly convertible to the underlying type. U may be either an integral that can be converted to T without a loss, or another Checked instance whose representation may be in turn converted to T without a loss.

this(U) (
  U rhs
)
if (valueConvertible!(U, T) || !isIntegral!T && is(typeof(T(rhs))) || is(U == Checked!(V, W), V, W) && is(typeof(Checked!(T, Hook)(rhs.get))));

Example

auto a = checked(42L);
writeln(a); // 42
auto b = Checked!long(4242); // convert 4242 to long
writeln(b); // 4242

Function Checked.this

Construct from a decimal string. The conversion follows the same rules as to converting a string to the wrapped T type.

this(Range) (
  Range str
)
if (isInputRange!Range && isSomeChar!(ElementType!Range));

Parameters

NameDescription
str an input range of characters

Example

to can convert a string to a Checked!T:

import std.conv : to;

const a = to!long("1234");
const b = to!(Checked!long)("1234");
writeln(a); // b

Authors

License