@@ -54,19 +54,19 @@ static unsigned int const MAX_EXTENDED_HEADER_LENGTH = 12;
5454// / Two byte conversion union
5555union uint16_converter {
5656 uint16_t i;
57- uint8_t c[ 2 ] ;
57+ std::array< uint8_t , 2 > c ;
5858};
5959
6060// / Four byte conversion union
6161union uint32_converter {
6262 uint32_t i;
63- uint8_t c[ 4 ] ;
63+ std::array< uint8_t , 4 > c ;
6464};
6565
6666// / Eight byte conversion union
6767union uint64_converter {
6868 uint64_t i;
69- uint8_t c[ 8 ] ;
69+ std::array< uint8_t , 8 > c ;
7070};
7171
7272// / Constants and utility functions related to WebSocket opcodes
@@ -234,28 +234,28 @@ struct basic_header {
234234// / The variable size component of a WebSocket frame header
235235struct extended_header {
236236 extended_header () {
237- std::fill_n (this ->bytes , MAX_EXTENDED_HEADER_LENGTH,0x00 );
237+ std::fill_n (this ->bytes . begin (), MAX_EXTENDED_HEADER_LENGTH, 0x00 );
238238 }
239239
240240 extended_header (uint64_t payload_size) {
241- std::fill_n (this ->bytes , MAX_EXTENDED_HEADER_LENGTH,0x00 );
241+ std::fill_n (this ->bytes . begin (), MAX_EXTENDED_HEADER_LENGTH, 0x00 );
242242
243243 copy_payload (payload_size);
244244 }
245245
246246 extended_header (uint64_t payload_size, uint32_t masking_key) {
247- std::fill_n (this ->bytes , MAX_EXTENDED_HEADER_LENGTH,0x00 );
247+ std::fill_n (this ->bytes . begin (), MAX_EXTENDED_HEADER_LENGTH, 0x00 );
248248
249249 // Copy payload size
250250 int offset = copy_payload (payload_size);
251251
252252 // Copy Masking Key
253253 uint32_converter temp32;
254254 temp32.i = masking_key;
255- std::copy (temp32.c , temp32.c + 4 , bytes+ offset);
255+ std::copy (temp32.c . begin (), temp32.c . end (), bytes. begin () + offset);
256256 }
257257
258- uint8_t bytes[ MAX_EXTENDED_HEADER_LENGTH] ;
258+ std::array< uint8_t , MAX_EXTENDED_HEADER_LENGTH> bytes ;
259259private:
260260 int copy_payload (uint64_t payload_size) {
261261 int payload_offset = 0 ;
@@ -268,7 +268,7 @@ struct extended_header {
268268
269269 uint64_converter temp64;
270270 temp64.i = lib::net::_htonll (payload_size);
271- std::copy (temp64.c + payload_offset,temp64.c + 8 , bytes);
271+ std::copy (temp64.c . begin () + payload_offset, temp64.c . begin () + 8 , bytes. begin () );
272272
273273 return 8 -payload_offset;
274274 }
@@ -494,7 +494,7 @@ inline std::string prepare_header(const basic_header &h, const
494494 ret.push_back (char (h.b0 ));
495495 ret.push_back (char (h.b1 ));
496496 ret.append (
497- reinterpret_cast <const char *>(e.bytes ),
497+ reinterpret_cast <const char *>(&* e.bytes . begin () ),
498498 get_header_len (h)-BASIC_HEADER_LENGTH
499499 );
500500
@@ -522,7 +522,8 @@ inline masking_key_type get_masking_key(const basic_header &h, const
522522 temp32.i = 0 ;
523523 } else {
524524 unsigned int offset = get_masking_key_offset (h);
525- std::copy (e.bytes +offset,e.bytes +offset+4 ,temp32.c );
525+ auto ptr = e.bytes .begin () + offset;
526+ std::copy (ptr, ptr + 4 , temp32.c .begin ());
526527 }
527528
528529 return temp32;
@@ -539,7 +540,7 @@ inline masking_key_type get_masking_key(const basic_header &h, const
539540 */
540541inline uint16_t get_extended_size (const extended_header &e) {
541542 uint16_converter temp16;
542- std::copy (e.bytes , e.bytes + 2 , temp16.c );
543+ std::copy (e.bytes . begin () , e.bytes . begin () + 2 , temp16.c . begin () );
543544 return ntohs (temp16.i );
544545}
545546
@@ -554,7 +555,7 @@ inline uint16_t get_extended_size(const extended_header &e) {
554555 */
555556inline uint64_t get_jumbo_size (const extended_header &e) {
556557 uint64_converter temp64;
557- std::copy (e.bytes , e.bytes + 8 , temp64.c );
558+ std::copy (e.bytes . begin (), e.bytes . begin () + 8 , temp64.c . begin () );
558559 return lib::net::_ntohll (temp64.i );
559560}
560561
0 commit comments