当前位置: 首页>>代码示例>>C++>>正文


C++ basic_ostream::fill方法代码示例

本文整理汇总了C++中std::basic_ostream::fill方法的典型用法代码示例。如果您正苦于以下问题:C++ basic_ostream::fill方法的具体用法?C++ basic_ostream::fill怎么用?C++ basic_ostream::fill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::basic_ostream的用法示例。


在下文中一共展示了basic_ostream::fill方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: insert_fill_chars

 inline void insert_fill_chars(std::basic_ostream<charT, traits>& os, std::size_t n) {
     enum { chunk_size = 8 };
     charT fill_chars[chunk_size];
     std::fill_n(fill_chars, static_cast< std::size_t >(chunk_size), os.fill());
     for (; n >= chunk_size && os.good(); n -= chunk_size)
         os.write(fill_chars, static_cast< std::size_t >(chunk_size));
     if (n > 0 && os.good())
         os.write(fill_chars, n);
     }
开发者ID:imos,项目名称:icfpc2015,代码行数:9,代码来源:string_ref.hpp

示例2: hex_dump

	inline void hex_dump(const void* aData, std::size_t aLength, std::basic_ostream<Elem, Traits>& aStream, std::size_t aWidth = 16)
	{
		const char* const start = static_cast<const char*>(aData);
		const char* const end = start + aLength;
		const char* line = start;
		while (line != end)
		{
			aStream.width(4);
			aStream.fill('0');
			aStream << std::hex << line - start << " : ";
			std::size_t lineLength = std::min(aWidth, static_cast<std::size_t>(end - line));
			for (std::size_t pass = 1; pass <= 2; ++pass)
			{	
				for (const char* next = line; next != end && next != line + aWidth; ++next)
				{
					char ch = *next;
					switch(pass)
					{
					case 1:
						aStream << (ch < 32 ? '.' : ch);
						break;
					case 2:
						if (next != line)
							aStream << " ";
						aStream.width(2);
						aStream.fill('0');
						aStream << std::hex << std::uppercase << static_cast<int>(static_cast<unsigned char>(ch));
						break;
					}
				}
				if (pass == 1 && lineLength != aWidth)
					aStream << std::string(aWidth - lineLength, ' ');
				aStream << " ";
			}
			aStream << std::endl;
			line = line + lineLength;
		}
	}
开发者ID:FlibbleMr,项目名称:neolib,代码行数:38,代码来源:hexdump.hpp


注:本文中的std::basic_ostream::fill方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。