私は現在、生データの配列またはベクトルを読み取る次の関数を持っています ( _readStreamis a std::ifstream) :
template<typename IteratorType>
inline bool MyClass::readRawData(
const IteratorType& first,
const IteratorType& last,
typename std::iterator_traits<IteratorType>::iterator_category* = nullptr
)
{
_readStream.read(reinterpret_cast<char*>(&*first), (last-first)*sizeof(*first));
return _readStream.good();
}
最初の質問: この機能は大丈夫ですか?
メモリのブロックを直接読み取るため、からのメモリ ブロックがメモリ内で連続しfirstている場合にのみ機能します。lastそれを確認する方法は?