11#include <userver/utils/meta_light.hpp>
13USERVER_NAMESPACE_BEGIN
21 decltype(std::declval<T&>() ? std::addressof(*std::declval<T&&>())
25inline constexpr bool kIsPointerLike = meta::kIsDetected<IsPointerLike, T>;
29template <
typename Leaf>
30constexpr auto* GetIf(Leaf&& leaf) {
31 if constexpr (impl::kIsPointerLike<Leaf>) {
32 return leaf ? utils::GetIf(*std::forward<Leaf>(leaf)) :
nullptr;
34 return std::addressof(std::forward<Leaf>(leaf));
42template <
typename Root,
typename Head,
typename... Tail>
43constexpr auto*
GetIf(Root&& root, Head&& head, Tail&&... tail) {
44 if constexpr (impl::kIsPointerLike<Root>) {
45 return root ? utils::GetIf(*std::forward<Root>(root),
46 std::forward<Head>(head),
47 std::forward<Tail>(tail)...)
51 std::invoke(std::forward<Head>(head), std::forward<Root>(root)),
52 std::forward<Tail>(tail)...);