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

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.

主站蜘蛛池模板: 白银市| 昭平县| 顺平县| 甘孜县| 洛南县| 贞丰县| 科技| 崇仁县| 西和县| 新晃| 公安县| 舒兰市| 五华县| 顺昌县| 钦州市| 靖江市| 黄梅县| 淅川县| 莒南县| 自贡市| 华安县| 巴南区| 平阳县| 商洛市| 德保县| 武鸣县| 禄劝| 卓尼县| 邻水| 社旗县| 枣庄市| 和平区| 宝山区| 南投市| 内丘县| 出国| 长寿区| 彭阳县| 涪陵区| 神池县| 醴陵市|