Couldn't the first argument T
be deduced from Container::value_type
?
CodePudding user response:
That would mean that to be used in a container adaptor, a container must provide a nested typedef value_type
. Certainly all of the containers in the standard library do so - but that's not the universe of possible containers.
Right now, stack
requires: Any sequence container supporting operations back()
, push_back()
and pop_back()
can be used to instantiate stack
.
CodePudding user response:
Container adapters are older thst C itself.
And they are a neater idea than they are practical. So they tend to be pretty neglected in my experience.
Plus, some unfortunate ABI choices of major vendors make adding or changing default parameters to templates an ABI breaking issue.
So, we get pre 20th century template arguments and no value_type deduction.
Also, stack<T>
seems like cleaner syntax than stack<deque<T>>
anyhow.