|
Boost : |
From: Matthias Troyer (troyer_at_[hidden])
Date: 2002-02-05 18:00:19
On Tuesday, February 5, 2002, at 11:06 PM, Andrei Alexandrescu wrote:
>> The std::stack and std::queue adaptors should work well of course.
>> What I have done is just simply adding a static constant,
>> "static_max_size", to there interface. Here is the complete
>> implementation of my fixed_capacity_stack.
>>
>> template<class T, std::size_t N,
>> template<class, std::size_t> class C = fixed_capacity_vector>
>> class fixed_capacity_stack : public std::stack<T, C<T, N> >
>> {
>> public:
>> static const std::size_t static_max_size = C<T, N>::static_max_size;
>>
>> }; // fixed_capacity_stack
>
> That's the wrong way of doing it. You don't inherit from a class just
> to add
> data members and/or functions. (It's true it was a popular idiom in
> early
> C++.)
>
> Andrei
How would you propose to do it?
Matthias
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk