From cefae593b3feb25896d0925b7433966791b3fe21 Mon Sep 17 00:00:00 2001 From: Krzysiek Karbowiak Date: Fri, 7 Feb 2025 00:08:10 +0100 Subject: [PATCH 1/2] Add ability to combine Handle values like bit masks --- include/argparse.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/argparse.h b/include/argparse.h index 1671bcef..a97852ee 100644 --- a/include/argparse.h +++ b/include/argparse.h @@ -65,6 +65,11 @@ namespace argparse using runtime_error::runtime_error; }; + inline auto operator|(Handle lhs, Handle rhs) -> Handle + { + return static_cast(static_cast(lhs) & static_cast(rhs)); + } + inline auto operator&(Handle lhs, Handle rhs) -> int { return static_cast(lhs) & static_cast(rhs); From 4f87e383d5ae8d3faf55d905d40304ec82f59d89 Mon Sep 17 00:00:00 2001 From: Krzysiek Karbowiak Date: Fri, 7 Feb 2025 00:10:08 +0100 Subject: [PATCH 2/2] Update tutorial --- tutorial/readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/tutorial/readme.md b/tutorial/readme.md index 731079e7..91e30deb 100644 --- a/tutorial/readme.md +++ b/tutorial/readme.md @@ -1169,6 +1169,7 @@ Some things to note here: * only version (`argparse::Handle::version`), * only errors (`argparse::Handle::errors`), * both help and errors (`argparse::Handle::errors_and_help`), + * any combination just like with bit masks (`argparse::Handle::errors | argparse::Handle::help`), * help, version, and errors (`argparse::Handle::errors_help_version`) which is the default. ## Conclusion