
me22 <me22.ca@gmail.com> wrote in news:fa28b9250703201126y574108d7r1c6f5f9d4584745a@mail.gmail.com:
Small thing I noticed in the implementation of template <typename ByteInputIterator> guid(ByteInputIterator first, ByteInputIterator last) { if (std::distance(first, last) != 16) { boost::throw_exception(std::invalid_argument("invalid input iterator pair, must span 16 bytes")); } data_type::iterator i_data = data_.begin(); while (first != last) { *i_data++ = numeric_cast<uint8_t>(*first++); } } You suggest that you want input iterators, and the invalid_argument message mentions input iterators, but your code doesn't work with input iterators as it traverses the range twice.
Good point! Thanks.
It should probably ask for forward iterators or use something like
template <typename ByteInputIterator> guid(ByteInputIterator first, ByteInputIterator last) { data_type::iterator i_data = data_.begin(); int i = 0; for (; i < 16 && first != last; ++i) { *i_data++ = numeric_cast<uint8_t>(*first++); } if ( i != 16 ) { boost::throw_exception(std::invalid_argument("invalid input iterator pair, must span at least 16 bytes")); } }
~ Scott McMurray
I will add this to my to do list. Andy. < snip >