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?

7

u/Fearless_Process Jun 14 '21

I think it has a lot to do with c/++ macros being untyped and unhygienic in general. This makes using them very much error prone and difficult to reason about when something goes wrong.

I think there is too much negative connotation around them though, they can be extremely useful when used properly.