官术网_书友最值得收藏!

2 Working with Numbers and Strings

Numbers and strings are the fundamental types of any programming language; all other types are based on or composed of these ones. Developers are confronted all the time with tasks such as converting between numbers and strings, parsing and formatting strings, and generating random numbers. This chapter is focused on providing useful recipes for these common tasks using modern C++ language and library features.

The recipes included in this chapter are as follows:

  • Converting between numeric and string types
  • Limits and other properties of numeric types
  • Generating pseudo-random numbers
  • Initializing all the bits of the internal state of a pseudo-random number generator
  • Creating cooked user-defined literals
  • Creating raw, user-defined literals
  • Using raw string literals to avoid escaping characters
  • Creating a library of string helpers
  • Verifying the format of a string using regular expressions
  • Parsing the content of a string using regular expressions
  • Replacing the content of a string using regular expressions
  • Using std::string_view instead of constant string references
  • Formatting text with std::format
  • Using std::format with user-defined types

Let's start this chapter by looking at a very common problem developers face on a daily basis, which is converting between numeric and string types.

主站蜘蛛池模板: 屯留县| 紫云| 武清区| 沭阳县| 五大连池市| 璧山县| 鹤庆县| 崇左市| 江安县| 平昌县| 镇江市| 萨嘎县| 苏尼特右旗| 景东| 冷水江市| 丹东市| 台东县| 广水市| 长阳| 惠州市| 出国| 饶平县| 黄浦区| 孝感市| 灵台县| 沧州市| 崇左市| 塘沽区| 敦化市| 仙游县| 汉川市| 竹山县| 昭平县| 巫山县| 义马市| 栖霞市| 中牟县| 竹溪县| 沾化县| 芦溪县| 松阳县|