Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Why did you use std::vector<> as the ops batch container instead of a generic iterator range?

  1. std::vector<async_io_op> is the closest thing to a variable length array in C++[13], at least until C++ 14 where we will gain std::dynarray<> and dynamic array sizing.
  2. std::vector<async_io_op> is well understood, particularly its performance during by-value copies and during push_back() which is by far the most common operation you do when preparing a batch.
  3. std::vector<async_io_op> is very amenable to splitting the batch across threads (not that AFIO currently does this).
  4. std::vector<async_io_op> is easily transportable through an ABI, whereas arbitrary container iterators would need type erasing (i.e. slow). As AFIO was developed initially as not header-only, this made a lot of sense initially.

We are not opposed to the use of generic iterator ranges in an AFIO v2 if there is user demand for such a thing.



[13] Ok, there is also the oft-forgotten std::valarray<> too, but its use as a generic container isn't recommended.


PrevUpHomeNext