C++ STL's String eqivalent for Binary Data

后端 未结 5 1728
北恋
北恋 2020-12-23 14:45

I am writing a C++ application and I was wondering what the C++ conventional way of storing a byte array in memory.

Is there something like a string, except specifi

5条回答
  •  情深已故
    2020-12-23 15:07

    There are multiple solutions but the closest one (I feel) is the std::vector> because it expresses the intent directly in code.

    From : https://en.cppreference.com/w/cpp/types/byte

    std::byte is a distinct type that implements the concept of byte as specified in the C++ language definition.

    Like char and unsigned char, it can be used to access raw memory occupied by other objects (object representation), but unlike those types, it is not a character type and is not an arithmetic type. A byte is only a collection of bits, and the only operators defined for it are the bitwise ones.

提交回复
热议问题