listings-Chap28-README.md
Listings of Chap28.docx
This is linked summary of the listings. You can also view it on one page.
- Listing 28.1: How to return two values simultaneously using “pair”.
- Book: lst-0001-book.cpp
- Godbolt: lst-0001-godb.cpp, https://godbolt.org/z/4YM9d99xG
- Listing 28.2: With “tuple”, you can return any number of elements.
- Book: lst-0002-book.cpp
- Godbolt: lst-0002-godb.cpp, https://godbolt.org/z/5z4s6WMxG
- Listing 28.3: “get” works with a type as an index.
- Book: lst-0003-book.cpp
- Godbolt: lst-0003-godb.cpp, https://godbolt.org/z/TE1EcEYPv
- Listing 28.4: Decomposing tuples with “tie” and “ignore”.
- Book: lst-0004-book.cpp
- Godbolt: lst-0004-godb.cpp, https://godbolt.org/z/zG7zYGf3K
- Listing 28.5: Tuples implement lexicographical order.
- Book: lst-0005-book.cpp
- Godbolt: lst-0005-godb.cpp, https://godbolt.org/z/sG4E66YhW
- Listing 28.6: Tuples as keys.
- Book: lst-0006-book.cpp
- Godbolt: lst-0006-godb.cpp, https://godbolt.org/z/9qhMo6zbb
- Listing 28.7: Forming tuples in-place using tie.
- Book: lst-0007-book.cpp
- Godbolt: lst-0007-godb.cpp, https://godbolt.org/z/vdT7TTjWK
- Listing 28.8: Combining several small tuples into one large tuple.
- Book: lst-0008-book.cpp
- Godbolt: lst-0008-godb.cpp, https://godbolt.org/z/eq1dqWbe9
- Listing 28.9: Useful tuple type traits.
- Book: lst-0009-book.cpp
- Godbolt: lst-0009-godb.cpp, https://godbolt.org/z/Psdz9s9Gc
- Listing 28.10: Matching, searching, and enumerating with regular expressions.
- Book: lst-0010-book.cpp
- Godbolt: lst-0010-godb.cpp, https://godbolt.org/z/T1YMoM5as
- Listing 28.11: Search and match.
- Book: lst-0011-book.cpp
- Godbolt: lst-0011-godb.cpp, https://godbolt.org/z/E9hcWGMW4
- Listing 28.12: Accessing the match details.
- Book: lst-0012-book.cpp
- Godbolt: lst-0012-godb.cpp, https://godbolt.org/z/Yzefv59en
- Listing 28.13: Replace matches with new text.
- Book: lst-0013-book.cpp
- Godbolt: lst-0013-godb.cpp, https://godbolt.org/z/rErP43G89
- Listing 28.14: Hard to maintain regular expression.
- Book: lst-0016-book.cpp
- Godbolt: lst-0016-godb.cpp, https://godbolt.org/z/dG5vE3heM
- Listing 28.15: Name parts and then combine them.
- Book: lst-0017-book.cpp
- Godbolt: lst-0017-godb.cpp, https://godbolt.org/z/TK6n4dG37
- Listing 28.16: Commenting within the expression.
- Book: lst-0018-book.cpp
- Godbolt: lst-0018-godb.cpp, https://godbolt.org/z/MszTjE3dv
- Listing 28.17: This is how you get a uniformly distributed random number between two bounds.
- Book: lst-0019-book.cpp
- Godbolt: lst-0019-godb.cpp, https://godbolt.org/z/ocP83a7ac
- Listing 28.18: Speeds of the random number generators.
- Book: lst-0023-book.cpp
- Godbolt: lst-0023-godb.cpp, https://godbolt.org/z/e67356bMq
- Listing 28.19: A binomial distribution.
- Book: lst-0024-book.cpp
- Godbolt: lst-0024-godb.cpp, https://godbolt.org/z/rv5fWP5Ya
- Listing 28.20: A “double” random number.
- Book: lst-0025-book.cpp
- Godbolt: lst-0025-godb.cpp, https://godbolt.org/z/94McsP7PG
- Listing 28.21: Change generation parameters for each random number individually.
- Book: lst-0026-book.cpp
- Godbolt: lst-0026-godb.cpp, https://godbolt.org/z/xz64qK3e5
- GodboltId:173nr4xxd
- Book: lst-0031-book.cpp
- Godbolt: lst-0031-godb.cpp, https://godbolt.org/z/173nr4xxd
- GodboltId:5snr1hq9b
- Book: lst-0032-book.cpp
- Godbolt: lst-0032-godb.cpp, https://godbolt.org/z/5snr1hq9b
- GodboltId:h8vsjxsME
- Book: lst-0034-book.cpp
- Godbolt: lst-0034-godb.cpp, https://godbolt.org/z/h8vsjxsME
- Listing 28.22: With “seconds”, you can perform calculations.
- Book: lst-0039-book.cpp
- Godbolt: lst-0039-godb.cpp, https://godbolt.org/z/47j8h9e7v
- Listing 28.23: You can compare “seconds”.
- Book: lst-0040-book.cpp
- Godbolt: lst-0040-godb.cpp, https://godbolt.org/z/8c1r5xrs5
- Listing 28.24: Automatic conversion between time units.
- Book: lst-0041-book.cpp
- Godbolt: lst-0041-godb.cpp, https://godbolt.org/z/qrs63vdz1
- Listing 28.26: You can mix units.
- Book: lst-0042-book.cpp
- Godbolt: lst-0042-godb.cpp, https://godbolt.org/z/vTx4cdqzq
- Listing 28.27: Create new time units or more efficient representations.
- Book: lst-0043-book.cpp
- Godbolt: lst-0043-godb.cpp, https://godbolt.org/z/xMz4s8K8K
- GodboltId:zMqjqMeav
- Book: lst-0044-book.cpp
- Godbolt: lst-0044-godb.cpp, https://godbolt.org/z/zMqjqMeav
- GodboltId:6z48xvvvM
- Book: lst-0045-book.cpp
- Godbolt: lst-0045-godb.cpp, https://godbolt.org/z/6z48xvvvM
- GodboltId:4s69W7qd3
- Book: lst-0047-book.cpp
- Godbolt: lst-0047-godb.cpp, https://godbolt.org/z/4s69W7qd3
- Listing 28.28: Output of date and time with format
- Book: lst-0049-book.cpp
- Godbolt: lst-0049-godb.cpp, https://godbolt.org/z/Md38b9zvf
- Listing 28.29: Always the second Tuesday of a month.
- Book: lst-0050-book.cpp
- Godbolt: lst-0050-godb.cpp, https://godbolt.org/z/19vf9jfTM
- Listing 28.30: Conversion to a time with time zone and the exceptions
- Book: lst-0052-book.cpp
- Godbolt: lst-0052-godb.cpp, https://godbolt.org/z/ezn568nof
- Listing 28.31: The time zone database.
- Book: lst-0053-book.cpp
- Godbolt: lst-0053-godb.cpp, https://godbolt.org/z/YTKK3vT7s
- GodboltId:ThM8q1zEP
- Book: lst-0054-book.cpp
- Godbolt: lst-0054-godb.cpp, https://godbolt.org/z/ThM8q1zEP
- GodboltId:q1znGWb85
- Book: lst-0059-book.cpp
- Godbolt: lst-0059-godb.cpp, https://godbolt.org/z/q1znGWb85
- Listing 28.32: Simple timing of a function call.
- Book: lst-0063-book.cpp
- Godbolt: lst-0063-godb.cpp, https://godbolt.org/z/3MGbYn4d5
- GodboltId:rz38hc1cx
- Book: lst-0064-book.cpp
- Godbolt: lst-0064-godb.cpp, https://godbolt.org/z/rz38hc1cx
- GodboltId:1xbhhTdEv
- Book: lst-0065-book.cpp
- Godbolt: lst-0065-godb.cpp, https://godbolt.org/z/1xbhhTdEv
- GodboltId:o359TThMj
- Book: lst-0066-book.cpp
- Godbolt: lst-0066-godb.cpp, https://godbolt.org/z/o359TThMj
- Listing 28.34: Very simple example of how to check the success of an operation.
- Book: lst-0067-book.cpp
- Godbolt: lst-0067-godb.cpp, https://godbolt.org/z/1xnY8vd8Y
- Listing 28.35: Comparison of “error_code” with “error_condition”.
- Book: lst-0068-book.cpp
- Godbolt: lst-0068-godb.cpp, https://godbolt.org/z/TPWc5nexq
- Listing 28.36: Overloads of “operator==()” (abbreviated).
- Book: lst-0069-book.cpp
- Listing 28.37: Definition of “enum class errc”.
- Book: lst-0070-book.cpp
- Listing 28.38: Specialization of “is_error_condition_enum” for “errc”.
- Book: lst-0071-book.cpp
- Listing 28.39: Among the overloads of “make_error_condition” is also one with “errc”.
- Book: lst-0072-book.cpp
- Listing 28.40: Generating system-specific error codes in a portable program.
- Book: lst-0073-book.cpp
- Godbolt: lst-0073-godb.cpp, https://godbolt.org/z/n4v78WWod
- GodboltId:11Tdr6aG1
- Book: lst-0074-book.cpp
- Godbolt: lst-0074-godb.cpp, https://godbolt.org/z/11Tdr6aG1
- GodboltId:a8zP84j1x
- Book: lst-0076-book.cpp
- Godbolt: lst-0076-godb.cpp, https://godbolt.org/z/a8zP84j1x
- GodboltId:cjh93oPcr
- Book: lst-0077-book.cpp
- Godbolt: lst-0077-godb.cpp, https://godbolt.org/z/cjh93oPcr
- Listing 28.41: Use “typeindex” for reliable type information.
- Book: lst-0078-book.cpp
- Godbolt: lst-0078-godb.cpp, https://godbolt.org/z/d1G9ez4KW
- Listing 28.42: Boost’s “demangled_name” is extremely useful for outputting type names.
- Book: lst-0079-book.cpp
- Godbolt: lst-0079-godb.cpp, https://godbolt.org/z/n54566cqT
- GodboltId:Y3GsPd97d
- Book: lst-0081-book.cpp
- Godbolt: lst-0081-godb.cpp, https://godbolt.org/z/Y3GsPd97d
- Listing 28.43: This calculator maps keys to functors.
- Book: lst-0082-book.cpp
- Godbolt: lst-0082-godb.cpp, https://godbolt.org/z/jxvhded75
- GodboltId:e6xT638ch
- Book: lst-0083-book.cpp
- Godbolt: lst-0083-godb.cpp, https://godbolt.org/z/e6xT638ch
- Listing 28.44: With “bind”, you can also set all parameters of a function.
- Book: lst-0084-book.cpp
- Godbolt: lst-0084-godb.cpp, https://godbolt.org/z/j7sa9rexh
- Listing 28.45: This is how you turn class members into free functions.
- Book: lst-0087-book.cpp
- Godbolt: lst-0087-godb.cpp, https://godbolt.org/z/GMjcjrvaT
- Listing 28.46: Basic functionalities of “variant”.
- Book: lst-0088-book.cpp
- Godbolt: lst-0088-godb.cpp, https://godbolt.org/z/baY7Tz91f
- Listing 28.47: Inspecting a “variant” using a visitor.
- Book: lst-0089-book.cpp
- Godbolt: lst-0089-godb.cpp, https://godbolt.org/z/G4z8Y5E6P
- GodboltId:1eco9Wcr3
- Book: lst-0090-book.cpp
- Godbolt: lst-0090-godb.cpp, https://godbolt.org/z/1eco9Wcr3
- GodboltId:115nE7xsc
- Book: lst-0093-book.cpp
- Godbolt: lst-0093-godb.cpp, https://godbolt.org/z/115nE7xsc
- GodboltId:dcqenEd31
- Book: lst-0095-book.cpp
- Godbolt: lst-0095-godb.cpp, https://godbolt.org/z/dcqenEd31