例如要傳入一個16字節(jié)大小的數(shù)組,傳統(tǒng)的做法是參數(shù)里面寫unsigned char*
可以改用如下方法:
typedef const unsigned char (&const_block) [16];
typedef unsigned char (&block) [16];
void test( const_block input, block output );
編譯器檢查會保證傳入的只能是固定大小的數(shù)組,不能是指針或者大小與指定值不同的數(shù)組。
可以改用如下方法:
typedef const unsigned char (&const_block) [16];
typedef unsigned char (&block) [16];
void test( const_block input, block output );
編譯器檢查會保證傳入的只能是固定大小的數(shù)組,不能是指針或者大小與指定值不同的數(shù)組。