Define a primitive data type: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 341:
 
/// Getter for the internal value
@property I internalValue() @property
{
return _value;
Line 363:
/// Unary operators
auto opUnary(string op)() const
{
return checked(mixin(op ~ "_value"));
Line 369:
/// Binary operators
auto opBinary(string op, T)(T other) const
{
return checked(mixin("_value" ~ op ~ "other"));
Line 375:
 
/// ditto
auto opBinaryRight(string op, T)(T other) const
if (isIntegral!T)
{
Line 382:
// Bounds enforcement
private I checked(T)(T value) const
{
enforce(value >= min && value <= max,
Anonymous user