r/cpp • • Jun 14 '21

match(it): A light-weight header-only pattern-matching library for C++17.

https://github.com/BowenFu/matchit.cpp
202 Upvotes

47 comments sorted by

View all comments

31

u/gracicot Jun 14 '21 edited Jun 14 '21

This is quite amazing what C++ can ship in a library, even though it's not perfect and uses macros.

12

u/[deleted] Jun 14 '21

Not arguing for them, but can someone explain the negative connotation around macros? I know the modern replacements are constexpr's and a lot of it has to do with lack of type definition, but is there more to it?

20

u/gracicot Jun 14 '21

Macro are textual and have no idea what C++ is and what C is. They don't have scope, cannot be isolated, and creates all sorts of problems, especially since C++ is using header to consume declarations from other translation units.