本文整理汇总了C++中StringStream::getloc方法的典型用法代码示例。如果您正苦于以下问题:C++ StringStream::getloc方法的具体用法?C++ StringStream::getloc怎么用?C++ StringStream::getloc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringStream
的用法示例。
在下文中一共展示了StringStream::getloc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_ops
void test_ops (const TempParams<T, CharT, Traits, Dist> ¶ms,
int line,
const char *input,
T expect,
bool is_eos,
int state)
{
typedef std::istream_iterator<T, CharT, Traits, Dist> Iterator;
typedef std::basic_stringstream<CharT, Traits> StringStream;
fmtnam (params.names);
StringStream strm;
typedef std::istreambuf_iterator<CharT, Traits> StreambufIterator;
typedef std::num_get<CharT, StreambufIterator> NumGet;
if (false == std::has_facet<NumGet>(strm.getloc ())) {
const std::locale loc (std::locale::classic (), new NumGet);
strm.imbue (loc);
}
if (input && *input)
strm << input;
const Iterator eos;
const Iterator it (strm);
rw_assert (is_eos ^ (it != eos), 0, line,
"line %d: %{$ITER}::operator() != %{$ITER}()", __LINE__);
if (0 == (strm.rdstate () & (strm.badbit | strm.failbit))) {
// operator*() is defined only for non-eos iterators
// avoid calling it on a bad or failed stream too
const T val = *it;
rw_assert (val == expect, 0, line,
"line %d: %{$ITER}::operator*() == %{@}, got %{@}",
__LINE__, params.names.tfmt, expect, params.names.tfmt, val);
}
rw_assert (strm.rdstate () == state, 0, line,
"line %d: %{$ITER}::operator*(), rdstate() == %{Is}, got %{Is}",
__LINE__, state, strm.rdstate ());
}