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

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.

主站蜘蛛池模板: 渭源县| 富裕县| 新密市| 太仆寺旗| 随州市| 平泉县| 新化县| 嘉义县| 郸城县| 田林县| 三江| 新河县| 彰化市| 玉田县| 邮箱| 富民县| 黄平县| 西平县| 枣强县| 岑巩县| 定远县| 万荣县| 思茅市| 普陀区| 天祝| 固始县| 金秀| 娱乐| 德江县| 河津市| 剑川县| 洞头县| 合山市| 延边| 苍山县| 玛沁县| 奉贤区| 当阳市| 禄丰县| 囊谦县| 河东区|