[Cryptography] bounded pointers in C

Nemo nemo at self-evident.org
Sat Apr 19 22:49:29 EDT 2014


Jerry Leichter <leichter at lrw.com> writes:

>>> But you can't, for example, have SafeInt constants.
>> 
>> Of course you can have SafeInt constants, just like you can have any
>> other type of const object:
>> 
>> static const SafeInt twelve(12);
>
> So now rather than writing:
>
> 	s = 12 * s;
>
> where s is a SafeInt, I have to first define a variable to hold 12?
> Sorry, but no.

Oh, I see... You meant "literal", not "constant".

You might be interested in C++11's user-defined literals, which let you
define "_safe" as a literal suffix so that you can write:

  s = 12_safe * s;

(Live example again: http://goo.gl/gvZrFt)

I concede the equivalent is messier in C++03. Although not by much; is
writing "SafeInt(12)" really so hard?

 - Nemo
   https://self-evident.org/


More information about the cryptography mailing list