Faking keyword arguments to functions in C++
a day ago
- #Language Features
- #C++ Programming
- #Keyword Arguments
- Python has keyword arguments that make APIs concise and readable.
- C and C++ lack keyword arguments; adding them would require significant effort and consensus.
- Attempts to implement keyword arguments in C++ using macros and templates have not gained widespread adoption.
- Modern C++ features can simulate keyword arguments using structs with designated initializers and in-place construction.
- The simulation involves extra syntax but allows for named parameters similar to Python's keyword arguments.