diff options
author | Brad King <brad.king@kitware.com> | 2024-07-04 14:09:58 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2024-07-04 14:10:07 (GMT) |
commit | 9c330283d664a6535c4cc283b1f53ab3bba5a392 (patch) | |
tree | cd8d80dcdc25d34f1f7e5e2f8c3d419fc66069d8 /Source | |
parent | ddcba76547a0a2fce7422e2cccce40c51708a600 (diff) | |
parent | 5fc2bad16741bec72c11463d61d7612aa231fb0e (diff) | |
download | CMake-9c330283d664a6535c4cc283b1f53ab3bba5a392.zip CMake-9c330283d664a6535c4cc283b1f53ab3bba5a392.tar.gz CMake-9c330283d664a6535c4cc283b1f53ab3bba5a392.tar.bz2 |
Merge topic 'cmArgumentParser-Derived-Classes'
5fc2bad167 cmArgumentParser: Support binding with derived classes
e0f9d81f09 STL: extend type_traits to deal with member pointers
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9634
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmArgumentParser.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Source/cmArgumentParser.h b/Source/cmArgumentParser.h index b35d7f3..c479b27 100644 --- a/Source/cmArgumentParser.h +++ b/Source/cmArgumentParser.h @@ -17,6 +17,7 @@ #include <cm/string_view> #include <cm/type_traits> #include <cmext/string_view> +#include <cmext/type_traits> #include "cmArgumentParserTypes.h" // IWYU pragma: keep @@ -244,8 +245,11 @@ class cmArgumentParser : private ArgumentParser::Base public: // I *think* this function could be made `constexpr` when the code is // compiled as C++20. This would allow building a parser at compile time. - template <typename T> - cmArgumentParser& Bind(cm::static_string_view name, T Result::*member) + template <typename T, typename cT = cm::member_pointer_class_t<T>, + typename mT = cm::remove_member_pointer_t<T>, + typename = cm::enable_if_t<std::is_base_of<cT, Result>::value>, + typename = cm::enable_if_t<!std::is_function<mT>::value>> + cmArgumentParser& Bind(cm::static_string_view name, T member) { this->Base::Bind(name, [member](Instance& instance) { instance.Bind(static_cast<Result*>(instance.Result)->*member); |