C ++固定长度字符串类? [英] C++ fixed length string class?

查看:124
本文介绍了C ++固定长度字符串类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在标准C ++ / STL 中有这样的内容吗?理想情况下,它应该像

  fstring s = fstring 

我需要有时构造或有一个固定大小的字符串。



编辑:



请注意,大小只在运行时才知道,并且彼此不同。但是所有的 fstring 应该知道如何一起工作,并具有所有的奇特 string 行为。

解决方案

今天最接近的是 boost :: array< char,10> p>

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

fstring s = fstring(10);

I need to sometimes construct or have a string of fixed size. Sometimes to be able to read / write only that many characters into a stream.

Edit:

Note that the size is only known at runtime, and is different from one to the other. But all of the fstrings should know how to work together and have all the fancy string behavior.

解决方案

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

这篇关于C ++固定长度字符串类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆