On Wednesday, 1 June 2016 at 19:59:51 UTC, Mark Isaacson wrote:
I'm trying to create a type that for all intents and purposes
behaves exactly like an int except that it limits its values to
be within a certain range [a,b]. Theoretically, I would think
this looks something like:
...
It looks
On 06/02/2016 07:59 AM, Ali Çehreli wrote:
> On 06/01/2016 12:59 PM, Mark Isaacson wrote:
>> I'm trying to create a type that for all intents and purposes behaves
>> exactly like an int except that it limits its values to be within a
>> certain range [a,b].
>
> 'alias this' with property
On 06/02/2016 04:59 PM, Ali Çehreli wrote:
'alias this' with property functions work at least for your example:
struct FixedRangeInt {
int min;
int max;
int i_;
int value() const {
return i_;
}
void value(int i) {
assert(i >= min);
On 06/01/2016 12:59 PM, Mark Isaacson wrote:
I'm trying to create a type that for all intents and purposes behaves
exactly like an int except that it limits its values to be within a
certain range [a,b].
'alias this' with property functions work at least for your example:
struct
On Wednesday, 1 June 2016 at 19:59:51 UTC, Mark Isaacson wrote:
FWIW, the fixed range int part of this question is just an
example, I'm mostly just interested in whether this idea is
possible without a lot of bloat/duplication.
I suspect not.. Here's how std.typecons.Proxy is doing it:
I'm trying to create a type that for all intents and purposes
behaves exactly like an int except that it limits its values to
be within a certain range [a,b]. Theoretically, I would think
this looks something like:
struct FixedRangeInt {
this(int min, int max, int value=0) {
this.min =