std::basic_stringbuf::basic_stringbuf
来自cppreference.com
< cpp | io | basic stringbuf
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
explicit basic_stringbuf(std::ios_base::openmode which = std::ios_base::in | std::ios_base::out); |
(1) | |
explicit basic_stringbuf (const std::basic_string<CharT, traits, Allocator>& new_str, std::ios_base::openmode which = std::ios_base::in |
(2) | |
basic_stringbuf(const basic_stringbuf& rhs) = delete; |
(3) | |
basic_stringbuf(basic_stringbuf&& rhs); |
(4) | (C++11 起) |
1)
构造一个
std::basic_stringbuf
对象初始化基类的默认构造函数调用std::basic_streambuf,初始化一个空字符串的字符序列,并设置模式which
的原文:
Constructs a
std::basic_stringbuf
object: initializes the base class by calling the default constructor of std::basic_streambuf, initializes the character sequence with an empty string, and sets the mode to which
.2)
构造一个
.std::basic_stringbuf
对象执行相同的初始化为1),然后初始化相应的字符序列,如果通过调用<div class="t-tr-text">STR(new_str)原文:
str(new_str)
这段文字是通过 [http://translate.google.com Google Translate] 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击[http://en.cppreference.com/w/Cppreference:MachineTranslations 这里]。
您可以帮助我们检查、纠正翻译中的错误。详情请点击[http://en.cppreference.com/w/Cppreference:MachineTranslations 这里]。
原文:
Constructs a
std::basic_stringbuf
object by performing the same initialization as 1), followed by initializing the associated character sequence as if by calling STR(new_str)</div>.
原文:
str(new_str)
这段文字是通过 [http://translate.google.com Google Translate] 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击[http://en.cppreference.com/w/Cppreference:MachineTranslations 这里]。
您可以帮助我们检查、纠正翻译中的错误。详情请点击[http://en.cppreference.com/w/Cppreference:MachineTranslations 这里]。
3)
拷贝构造函数被删除;
std::basic_stringbuf
是不CopyConstructible
原文:
The copy constructor is deleted;
std::basic_stringbuf
is not CopyConstructible
4)
移动构建了一个移动的所有状态从另一个
std::basic_stringbuf
对象的std::basic_stringbuf
,包括相关的字符串,开模,和所有其他国家的语言环境,rhs
对象。六指针后移,std::basic_streambuf在*this保证不同,相应的指针移离rhs
,除非空.原文:
Move-constructs a
std::basic_stringbuf
object by moving all state from another std::basic_stringbuf
object rhs
, including the associated string, the open mode, the locale, and all other state. After the move, the six pointers of std::basic_streambuf in *this are guaranteed to be different from the corresponding pointers in the moved-from rhs
unless null.目录 |
[编辑] 参数
new_str | - | 一个
basic_string 用于初始化缓冲区 原文: a basic_string used to initialize the buffer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rhs | - | 另一个
basic_stringbuf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
mode | - | 指定流的开放模式。这是位掩码类型,有以下常量的定义:
原文: specifies stream open mode. It is bitmask type, the following constants are defined:
|
[编辑] 注释
std::basic_stringstream的构造函数通常被称为.
原文:
Typically called by the constructor of std::basic_stringstream.
支持的开放模式以外std::ios_base::instd::ios_base::out的水平不同的实现。 C + +11中明确规定的支持std::ios_base::ate
str()
,并在此构造函数,但std::ios_base::app,std::ios_base::trunc,std::ios_base::binary有不同的影响,在不同的实现.原文:
The level of support for the open modes other than std::ios_base::in and std::ios_base::out varies among implementations. C++11 explicitly specifies the support for std::ios_base::ate in
str()
and in this constructor, but std::ios_base::app, std::ios_base::trunc, and std::ios_base::binary have different effects on different implementations.[编辑] 示例
演示如何直接调用构造函数的basic_stringbuf .
原文:
Demonstrates calling the constructor of basic_stringbuf directly.
#include <iostream> #include <sstream> int main() { // default constructor (mode = in|out) std::stringbuf buf1; buf1.sputc('1'); std::cout << &buf1 << '\n'; // string constructor in at-end mode (C++11) std::stringbuf buf2("test", std::ios_base::in | std::ios_base::out | std::ios_base::ate); buf2.sputc('1'); std::cout << &buf2 << '\n'; // append mode test (results differ among compilers) std::stringbuf buf3("test", std::ios_base::in | std::ios_base::out | std::ios_base::app); buf3.sputc('1'); buf3.pubseekpos(1); buf3.sputc('2'); std::cout << &buf3 << '\n'; }
输出:
1 test1 est12 (Sun Studio) 2st1 (GCC)
[编辑] 另请参阅
构造字符串流 (公共成员函数of std::basic_stringstream )
|