Strong size_t
Simen Kjærås
simen.kjaras at gmail.com
Sat Nov 26 08:34:30 PST 2011
On Sat, 26 Nov 2011 17:22:58 +0100, Kagamin <spam at here.lot> wrote:
> Tried to create a stronger version of size_t which will not interoperate
> with int and long
> http://codepad.org/47OB3nJi
>
> But for some reason can't compare struct to int using opEquals and
> opCmp. How to fix it? And should it? One can write `v==intp(42)` or
> `v<intp(43)`.
Have you tried to overload opEquals and opCmp for ints? That seems to
work just fine for me:
bool opEquals(int v) const { return value == v; }
int opCmp(int v) const
{
return value>v?1:value<v?-1:0;
}
Just add those to the intp struct.
More information about the Digitalmars-d-learn
mailing list