Skip to content

UFCS try to get pointer using get() after other matches failed #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions include/cpp2util.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@
#include <utility>
#include <variant>
#include <memory>
#ifdef __cpp_lib_memory_resource
#if __has_include(<memory_resource>)
#include <memory_resource>
#elif __has_include(<experimental/memory_resource>)
#include <experimental/memory_resource>
#endif
#include <new>
#include <scoped_allocator>
Expand All @@ -106,7 +108,9 @@
#include <cctype>
#include <charconv>
#include <cstring>
#include <cuchar>
#if __has_include(<cuchar>)
#include <cuchar>
#endif
#include <cwchar>
#include <cwctype>
#ifdef __cpp_lib_format
Expand Down Expand Up @@ -174,7 +178,9 @@
#include <semaphore>
#endif
#include <shared_mutex>
#include <stop_token>
#if __has_include(<stop_token>)
#include <stop_token>
#endif
#include <thread>
#include <iso646.h>
#endif
Expand Down Expand Up @@ -455,6 +461,10 @@ class out {
[](auto&& obj, auto&& ...params) { \
if constexpr (requires{ std::forward<decltype(obj)>(obj).FUNCNAME(std::forward<decltype(params)>(params)...); }) { \
return std::forward<decltype(obj)>(obj).FUNCNAME(std::forward<decltype(params)>(params)...); \
} else if constexpr ( requires{ FUNCNAME(std::forward<decltype(obj)>(obj), std::forward<decltype(params)>(params)...); }){ \
return FUNCNAME(std::forward<decltype(obj)>(obj), std::forward<decltype(params)>(params)...); \
} else if constexpr (requires{ FUNCNAME(std::forward<decltype(obj.get())>(obj.get()),std::forward<decltype(params)>(params)...); }) { \
return FUNCNAME(std::forward<decltype(obj.get())>(obj.get()), std::forward<decltype(params)>(params)...); \
} else { \
return FUNCNAME(std::forward<decltype(obj)>(obj), std::forward<decltype(params)>(params)...); \
} \
Expand All @@ -464,6 +474,10 @@ class out {
[](auto&& obj) { \
if constexpr (requires{ std::forward<decltype(obj)>(obj).FUNCNAME(); }) { \
return std::forward<decltype(obj)>(obj).FUNCNAME(); \
} else if constexpr ( requires{ FUNCNAME(std::forward<decltype(obj)>(obj)); }) { \
return FUNCNAME(std::forward<decltype(obj)>(obj)); \
} else if constexpr (requires{ FUNCNAME(std::forward<decltype(obj.get())>(obj.get())); }) { \
return FUNCNAME(std::forward<decltype(obj.get())>(obj.get())); \
} else { \
return FUNCNAME(std::forward<decltype(obj)>(obj)); \
} \
Expand Down