2

I'm using a boost array as buffer for the content I get from the async_read of the boost::asio.

After reading I want to clear/reset the buffer for the next read. Please tell me how can i do this.

Manoj
  • 5,542
  • 9
  • 54
  • 80
  • Do you want the clear() functionality of std::vector? If not, what is that you expect array clear() to do? – yasouser Jan 07 '11 at 15:41

1 Answers1

7

You do not need to clean each reading, just use the amount of bytes read buffer(array, bytes_readed)

In case you still want, you can use the assign method array.assign(0);

osmano807
  • 134
  • 1
  • 8
  • Hm, current g++ compiler does not seem to support the `assign` method :( – fredoverflow Jan 07 '11 at 14:51
  • your_array.assign( the_default_value_of_array_elem ); is the only way you can fill the array with the default value of your choice. assign() does this: std::fill_n(begin(), N, value) {quoting from http://www.boost.org/doc/libs/1_45_0/doc/html/boost/array.html#id426226-bb} – yasouser Jan 07 '11 at 15:51