本文整理汇总了C++中ostream::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ ostream::clear方法的具体用法?C++ ostream::clear怎么用?C++ ostream::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ostream
的用法示例。
在下文中一共展示了ostream::clear方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: min
ostream& __STL_CALL operator<<(ostream& __os,
const basic_string<_CharT,_Traits,_Alloc>& __s)
{
__STL_USING_VENDOR_STD
streambuf* __buf = __os.rdbuf();
if (__buf) {
size_t __n = __s.size();
size_t __pad_len = 0;
const bool __left = (__os.flags() & ios::left) !=0;
const size_t __w = __os.width();
if (__w > 0) {
__n = min(__w, __n);
__pad_len = __w - __n;
}
if (!__left)
__sgi_string_fill(__os, __buf, __pad_len);
const size_t __nwritten = __buf->sputn(__s.data(), __n);
if (__left)
__sgi_string_fill(__os, __buf, __pad_len);
if (__nwritten != __n)
__os.clear(__os.rdstate() | ios::failbit);
__os.width(0);
}
else
__os.clear(__os.rdstate() | ios::badbit);
return __os;
}
示例2: reset
MVS_API void reset(ostream& os) noexcept
{
os.clear();
os.fill(os.widen(' '));
os.flags(ios_base::skipws | ios_base::dec);
os.precision(6);
os.width(0);
};
示例3: printHeading
void printHeading( ostream& outs, string title, int width )
{
//Declare Variables
int magic_width = 0;
magic_width = (width/2) - (title.length()/2) + title.length();
outs << "\n";
printHorizontalLine( outs, '*', width);
outs << right << setfill(' ') << setw( magic_width ) << title << "\n";
printHorizontalLine( outs, '*', width);
//reset cout
outs.clear();
outs.fill(' ');
}
示例4: ReportResults
void RandomSampleJob::ReportResults (ostream& r)
{
bool errorOccured = false;
do
{
errorOccured = false;
r << jobId << "\t"
<< KernalTypeToStr (config->KernalType ()) << "\t"
<< EncodingMethodToStr (config->EncodingMethod ()) << "\t"
<< CompressionMethodStr (compMethod) << "\t"
<< config->C_Param () << "\t"
<< config->Gamma () << "\t"
<< orderingNum << "\t"
<< numExamplesToKeep << "\t"
<< Accuracy () << "%" << "\t"
<< SupportVectors () << "\t"
<< trainTime << "\t"
<< testTime
<< endl;
r.flush ();
if (r.fail ())
{
r.clear ();
errorOccured = true;
#ifdef WIN32
Sleep (30000);
#else
sleep (30);
#endif
}
} while (errorOccured);
} /* ReportResults */
示例5: print_stream
// Threadsafe print a given stream.
void print_stream(ostream &strng)
{
cout << strng.rdbuf();
cout.flush();
strng.clear();
}