Subject: Re: [boost] [Opaque] Request for interest in Opaque typedefs library emulation
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2010-05-07 13:54:53
> The library include two class templates (CRTP) to define opaque types:
> * public_opaque_type<OT,UT> : implicit conversion from OT to UT
> * private_opaque_type<OT,UT> : no conversion from OT to UT
Why not name them typedef_public and typedef_private to correlate with the proposed syntax?
> To define a new OT with this mixin classes
> struct serial_number: public_opaque_type<serial_number, unsigned>
> struct game_score: private_opaque_type<game_score, unsigned>
Can you imagine any use case in which someone would want to add anything else to such a type? They won't be able to if opaque types ever become part of the standard, will they?
> In addition, defines macros that make this simpler
> BOOST_OPAQUE_PUBLIC_TYPEDEF(unsigned, serial_number);
> BOOST_OPAQUE_PRIVATE_TYPEDEF(unsigned, game_score);
> Next follows the definition of the public_opaque_type
> template <typename Final, typename T>
> class public_opaque_type
> : boost::totally_ordered< Final
> , boost::integer_arithmetic< Final
> , boost::bitwise< Final
> , boost::unit_steppable< Final
> , boost::totally_ordered< T, Final // public
> specific conversions
> , boost::integer_arithmetic< T, Final // public
> specific conversions
> , boost::bitwise< T, Final // public specific conversions
> > > > > > > >
That's quite a collection of mixins!
> Please, let me know if you see a error on the design.
At first blush, it seems reasonable, but you'll need to test a great variety of use cases to make sure they do only what they should and in many contexts.
Here are a few questions that spring to mind:
Can you declare such types local to a function?
Can you declare such types nested within a UDT?
Can you declare such types with others as the underlying type?
Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP http://www.sig.com
IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk