typename std::iterator_traits<IteratorType>::iterator_category* = nullptr
, std::iterator_traits iterator_category. , , - SFINAE, , .
When we read the memory block directly, it will work only if the memory block from the first to the last is continuous in memory. How to check it?
I do not know what exact requirements you would put in the concept of "contiguous in memory." However, did you consider the following?
template<typename T>
bool readRawData(T* first, T* last);
with a precondition, which [ first, last )is a valid range of pointer-and-iterator to an array.
If you want to add additional requirements to T(for example, trivial copyability, as you use read), you can also express and document them.
source
share