|
Boost : |
From: dexsch (DavidS_at_[hidden])
Date: 2002-02-19 22:19:07
--- In boost_at_y..., "Noah Stein" <noah_at_v...> wrote:
> > -----Original Message-----
> > From: dexsch [mailto:DavidS_at_a...]
> > Sent: Tuesday, February 19, 2002 5:48 PM
>
> >
> > Here is an example of a meta type definition.
> >
> > // This says ListNode types must
> > // declare a typedef value_type,
> > // have a copy constructor,
> > // and a next() method which returns a ListNode*
> > // and an equality comparison operator
> > // Remember the name ListNode is a place holder
> > // for the actual type(s) being constrained
> > typespec ListNode
> > {
> > public:
> > typedef value_type;
> > ListNode(const ListNode&)
> > ListNode* next();
> > bool operator==(const ListNode&)
> > };
>
>
> I like the idea here, but I would prefer a notation that does not
introduce
> a keyword. I would suggest using a notation similar to that used
by pure
> virtual functions:
>
> typename ListNode = 0
> {
> public:
> typedef value_type;
> ListNode(const ListNode&);
> ListNode* next();
> bool operator==(const ListNode&);
> };
>
> The issues I still see with the above is that the "typedef
value_type;" is
> different than the normal syntax for typedef.
You're right that should read
typename value_type;
// which indicates that ListNode introduces a new type name
The pure syntax (= 0) following typename would be unnecessary
typename could be a direct replacement for typespec.
This elevates the typename keyword from a place holder
to a syntactic element in it's own right and create
a metatypes name space outside the class/struct/typedef namespace(s).
dex
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk