Den 06-10-2017 kl. 11:53 skrev Thorsten Ottosen via Boost:
Den 05-10-2017 kl. 22:42 skrev Ion Gaztañaga via Boost:
On 05/10/2017 19:02, Thorsten Ottosen via Boost wrote:
I was thinking along generic code along the line
template< class BacKInsertionContiguousContainer > void foo( BacKInsertionContiguousContainer& cont ) { cont.reserve( source.size() ); for( ... ) cont.push_back( ... );
}
why should that not work with both devector and vector?
It would work, but it would not be as efficient as vector.
It may be. But I guess my concern was to make it compile. Sure, if a call to reserve is conditioned on d.capacity() - d.size(), it can behave differently. Reserve maybe easier to do something about.
What if we did this: capacity() -> alias for back_capacity back_capacity() -> return size() + back_free_capacity() front_capacity() -> return size() + front_free_capacity() ? kind regards Thorsten