Obtaining a pointer to the end of an array

后端 未结 3 870
走了就别回头了
走了就别回头了 2021-02-02 17:34

I use the following template to obtain a pointer pointing after the last element of an array:

template 
T* end_of(T (&array)[n])
         


        
3条回答
  •  北恋
    北恋 (楼主)
    2021-02-02 17:46

    You need a const version too. However, as far as I know, there's no actual problems with that approach- I see it used commonly.

提交回复
热议问题