4 Better modern C++: Additional topics

 

This chapter covers

  • Improvements in text formatting
  • Regular expressions
  • Lambdas
  • Variadic templates
  • Portable filesystem code

Modern C++ has expanded the range and depth of functionality available for developers. Many areas have improved, and well-designed and articulated recommendations have entered the standard. This chapter is a very sparse sampling of a few features that make everyday programming simpler, more correct, and easier to read.

Almost any C++ developer would benefit from these additional topics but argue that some crucial aspects have been overlooked. This assessment is correct, since there are too many nifty features to enumerate. However, consider this effort a starting point in a general approach to picking up some handy improvements.

Text handling has improved, using the not-yet-implemented-everywhere format header. Parsing text by writing your code is fraught with complexity and errors, but regular expression functionality simplifies developers’ lives.

4.1 Mistake 18: Not using variadic templates

4.2 Mistake 19: Using global namespace enums

4.3 Mistake 20: Not using new formatting functionality

4.4 Mistake 21: Not using ranges with containers

4.5 Mistake 22: Writing nonportable filesystem code

4.6 Mistake 23: Writing excessive standalone functions

4.7 Mistake 24: Using awkward constants

4.8 Mistake 25: Writing pattern-matching code