Subject: Re: [boost] Re : Interest in specialized types
From: Henning Basold (h.basold_at_[hidden])
Date: 2010-08-22 14:34:16
Am 22.08.2010 18:29, schrieb Pierre Morcello:
> Henning Basold wrote :
>> > Robert Ramey talked about wrapping some POD to increase type
>> > safety. Some time ago I used something similar to ensure
>> > that misuse of values can be found by the compiler.
>> > So I think that is something that can be generalized. The
>> > concept is to wrap a type into a class and restrict the
>> > interface. This ensures that values from one context (e.g.
>> > an id) can't be used in another context (e.g. adding of
>> > number or as an id for other objects).
>> > Do you think this might be a useful utility? Or is there
>> > something similar already available? [...]
> Personnaly, I simply use a strongtypedef macro. A good news is that there is already one done in serialization : strong_typedef.hpp (maybe this one could have gone into boost.utility?).
> I think you have got something to dig, even if I am not convinced that I would use your interface in a real project over the already existing strong_typedef. Could you give some real world cunny examples of use?
> Best regards,
> Pierre Morcello
> Unsubscribe& other changes:http://lists.boost.org/mailman/listinfo.cgi/boost
now that you mention it I'm remembering the existence of strong_typedef.
The main use case I had in mind were ID objects that are generated to
identify objects somewhere. I used them to decouple references to
objects from the containers and to easily serialize them.
To find more interesting examples I have to think a bit :)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk