I had issues when constructing spans from std::arrays with size 0 in Visual Studio. In Debug builds it has its container debugging mode for the standard library enabled (_CONTAINER_DEBUG_LEVEL > 0) and breaks on an assertion error when operator[] is called with 0. I then tried the stdlibc++ debug mode (-D_GLIBCXX_DEBUG) and it shows the same problem. I guess that technically &arr[0] is not a bug, but practically it can become a problem with these debug modes. I couldn't think of a disadvantage of using .data(), so I propose to use that instead.
I had issues when constructing spans from
std::array
s with size 0 in Visual Studio. In Debug builds it has its container debugging mode for the standard library enabled (_CONTAINER_DEBUG_LEVEL > 0
) and breaks on an assertion error whenoperator[]
is called with 0. I then tried the stdlibc++ debug mode (-D_GLIBCXX_DEBUG
) and it shows the same problem. I guess that technically&arr[0]
is not a bug, but practically it can become a problem with these debug modes. I couldn't think of a disadvantage of using.data()
, so I propose to use that instead.