This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Deque::fill


Paolo Carlini wrote:

+ template<typename _Tp, typename _Ref, typename _Ptr>
+ struct _Deque_iterator;
+
+ template<typename _Tp, typename _Ref, typename _Ptr>
+ void
+ fill(const _Deque_iterator<_Tp, _Ref, _Ptr>& __first,
+ const _Deque_iterator<_Tp, _Ref, _Ptr>& __last, const _Tp& __value)
+ {
+ typedef typename _Deque_iterator<_Tp, _Ref, _Ptr>::_Self _Self;
+
+ for (typename _Self::_Map_pointer __node = __first._M_node + 1;
+ __node < __last._M_node; ++__node)
+ std::fill(*__node, *__node + _Self::_S_buffer_size(), __value);
+
On a similar note to some simplifications in vector, would it be better to "admit" that the size of a buffer is a compile-time constant, and make it a static const, rather than a function call?

I mainly ask as I had a look a while ago at simplifying deque in the case that the objects are big enough it "degrades" into a vector of pointers to pointers. While the best simplifications would require ABI-breaking, it's possible to overload things like operator++, operator+, etc on _Deque_iterators with simpler versions which the compiler doesn't seem capable of deducing by itself.

Chris


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]