Anyone who has used 'deque' in performance critical code probably has noticed that (at least in the STL shipped with VS2010) that the block size is 16 bytes. This is the actual snippit from the header file shipped with VS2010:
#define _DEQUESIZ (sizeof (value_type) <= 1 ? 16 \
: sizeof (value_type) <= 2 ? 8 \
: sizeof (value_type) <= 4 ? 4 \
: sizeof (value_type) <= 8 ? 2 \
: 1) /* elements per block (a power of 2) */
This is not new information, see About deque<T>'s extra indirection for more details as to why this decl causes performance issues.
I would like to use a deque in various algorithms, but not if I'm constrained to this implementation. What's the best way to go about circumventing this issue?
1) Use another container that doesn't have this problem. If so, can someone point me to one that has no GNU license restrictions?
2) Create a new container class that addresses this limitation. This new container class would not be part of the std namespace.
3) Edit the _DEQUESIZ definition in the 'deque' header file. IMO, I think this is legal, since the exact specification of _DEQUESIZ is not part of the deque concept, as defined by the STL.
4) Add an additional template parameter to deque (and associated iterator classes) to allow block size to be specified at compile time. This parameter would default to the current definition of _DEQUESIZ. I pretty much am rejecting this solution, since now my code using this bastardized STL is not portable.
5) Lobby congress to get STL changed so I can happily use 'deque' without performance issues. IMO, this might have more success than the current fiscal cliff debate. BTW, I'm Canadian, so the whole House + Senate + President rigmarole is confusing.