1 /** 2 * Authors: Alex 'asperan' Speranza, alex.speranza@studio.unibo.it 3 * License: 4 * MIT License 5 * 6 * Copyright (c) 2021 Alex Speranza 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining a copy 9 * of this software and associated documentation files (the "Software"), to deal 10 * in the Software without restriction, including without limitation the rights 11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 * copies of the Software, and to permit persons to whom the Software is 13 * furnished to do so, subject to the following conditions: 14 * 15 * The above copyright notice and this permission notice shall be included in all 16 * copies or substantial portions of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 * SOFTWARE. 25 */ 26 module boxed.integers; 27 28 import boxed.templates; 29 30 /** 31 * Boxed byte value. 32 */ 33 class BoxedByte : Boxed!byte 34 { 35 /** 36 * Ctor. 37 */ 38 this(byte value) 39 { 40 super(value); 41 } 42 43 mixin BoxedAlias; 44 } 45 46 /** 47 * Boxed unsigned byte value. 48 */ 49 class BoxedUbyte : Boxed!ubyte 50 { 51 /** 52 * Ctor. 53 */ 54 this(ubyte value) 55 { 56 super(value); 57 } 58 59 mixin BoxedAlias; 60 } 61 62 /** 63 * Boxed short value. 64 */ 65 class BoxedShort : Boxed!short 66 { 67 /** 68 * Ctor. 69 */ 70 this(short value) 71 { 72 super(value); 73 } 74 75 mixin BoxedAlias; 76 } 77 78 /** 79 * Boxed unsigned short value. 80 */ 81 class BoxedUshort : Boxed!ushort 82 { 83 /** 84 * Ctor. 85 */ 86 this(ushort value) 87 { 88 super(value); 89 } 90 91 mixin BoxedAlias; 92 } 93 94 /** 95 * Boxed signed integer value. 96 * 97 * Assign operation are not supported. 98 */ 99 class BoxedInt : Boxed!int 100 { 101 /** 102 * Ctor. 103 */ 104 this(int value) 105 { 106 super(value); 107 } 108 109 mixin BoxedAlias; 110 } 111 112 unittest 113 { 114 BoxedInt bi = new BoxedInt(3); 115 assert(bi + 4 == 7); 116 assert(!__traits(compiles, bi += 3)); 117 } 118 119 /** 120 * Boxed unsigned integer value. 121 * 122 * Assign operation are not supported. 123 */ 124 class BoxedUint : Boxed!uint 125 { 126 /** 127 * Ctor. 128 */ 129 this(uint value) 130 { 131 super(value); 132 } 133 134 mixin BoxedAlias; 135 } 136 137 /** 138 * Boxed signed long value. 139 * 140 * Assign operation are not supported. 141 */ 142 class BoxedLong : Boxed!long 143 { 144 /** 145 * Ctor. 146 */ 147 this(long value) 148 { 149 super(value); 150 } 151 152 mixin BoxedAlias; 153 } 154 155 /** 156 * Boxed unsigned long value. 157 * 158 * Assign operation are not supported. 159 */ 160 class BoxedUlong : Boxed!ulong 161 { 162 /** 163 * Ctor. 164 */ 165 this(ulong value) 166 { 167 super(value); 168 } 169 170 mixin BoxedAlias; 171 }