私は現在、生データの配列またはベクトルを読み取る次の関数を持っています ( _readStream
is 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
それを確認する方法は?