1 import checkedint.throws : SmartInt; // use IntFlagPolicy.throws 2 3 assert(is(typeof(bits(5)) == int)); 4 5 SmartInt!(int, No.bitOps) noBits = 5; 6 assert(is(typeof(bits(noBits)) == SmartInt!(int, Yes.bitOps))); 7 8 static assert(!__traits(compiles, noBits << 2)); 9 assert((bits(noBits) << 2) == 20);
Get a view or copy of num that supports bitwise operations.
Useful in generic code that handles both basic types and checkedint types.