c++ - How can Boost.Asio create a buffer object of size equal to the size of the array? -
consider following lines (boost/c++):
char d1[128]; size_t bytes_transferred = sock.receive(boost::asio::buffer(d1));
the boost.asio documentation states buffer of size 128 created.
but how can boost determine size of array? i've read several questions, answer size of array cannot determined in c++.
there template specialization arrays size known @ compile time http://www.boost.org/doc/libs/1_60_0/doc/html/boost_asio/reference/buffer/overload7.html
template< typename podtype, std::size_t n> mutable_buffers_1 buffer( podtype (&data)[n]);
in c++ 'char[5]', 'char[128]' , 'char*' different types compiler can take advantage of http://www.cplusplus.com/faq/sequences/arrays/sizeof-array/#cpp
Comments
Post a Comment