C++ fixed length string class?

前端 未结 10 1083
遇见更好的自我
遇见更好的自我 2020-12-17 17:56

Is there anything like this in Standard C++ / STL? Ideally it should be constructed like

fstring s = fstring(10);

I need to sometimes cons

相关标签:
10条回答
  • 2020-12-17 18:40

    The closest approximation today is boost::array<char, 10>

    0 讨论(0)
  • 2020-12-17 18:40

    Use e.g.

    std::tr1::array<char, 10>
    
    0 讨论(0)
  • 2020-12-17 18:41

    With ISO C++ +17 you can do this

    #include <string_view>
    ......
    char dataBuffer[BUFF_SIZE];
    auto commandString = std::string_view{ dataBuffer };
    ......
    
    0 讨论(0)
  • 2020-12-17 18:47

    C style character array?

    char label[10] = "a string";
    
    0 讨论(0)
提交回复
热议问题