Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import std.traits;
- import std.stdio;
- static
- ubyte[] packVarint(T)( T value )
- if( isIntegral!T && isUnsigned!T )
- out( arr )
- {
- writeln( "Inside of out contract: value=", value, " type=", typeid( typeof(value) ), " result=", arr );
- }
- body
- {
- writeln( "Inside of body: value=", value, " type=", typeid( typeof(value) ) );
- ubyte[] res;
- immutable ubyte maximal = 0b_1000_0000;
- while( value >= maximal )
- {
- res ~= cast( ubyte )( value | maximal );
- value >>= 7;
- }
- import std.conv: to;
- res ~= to!( ubyte )( value );
- return res;
- }
- void main()
- {
- ulong v = 300;
- packVarint( v );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement