LeechCraft  0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
typegetter.h
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2014 Georg Rudoy
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7  **********************************************************************/
8 
9 #pragma once
10 
11 #include <tuple>
12 
13 namespace LC::Util
14 {
15  namespace detail
16  {
17  template<typename R, typename... Args>
18  std::tuple<R, Args...>* TypeGetter (R (*) (Args...));
19 
20  template<typename F>
21  auto TypeGetter (F&& f) -> decltype (TypeGetter (+f));
22 
23  template<typename C, typename R, typename... Args>
24  std::tuple<R, Args...>* TypeGetter (R (C::*) (Args...) const);
25 
26  template<typename C, typename R, typename... Args>
27  std::tuple<R, Args...>* TypeGetter (R (C::*) (Args...));
28 
29  template<typename C>
30  decltype (TypeGetter (&C::operator ())) TypeGetter (const C& c);
31 
32  template<typename F>
33  using CallTypeGetter_t = std::decay_t<decltype (*detail::TypeGetter (*static_cast<F*> (nullptr)))>;
34  }
35 
36  template<typename F>
38 
39  template<SomeInvokable F, size_t Idx>
40  using ArgType_t = std::tuple_element_t<Idx + 1, detail::CallTypeGetter_t<F>>;
41 
42  template<SomeInvokable F>
43  using RetType_t = std::tuple_element_t<0, detail::CallTypeGetter_t<F>>;
44 
45  template<SomeInvokable F>
46  inline constexpr auto ArgCount_v = std::tuple_size_v<detail::CallTypeGetter_t<F>> - 1;
47 
48  namespace detail
49  {
50  template<typename>
52  {
53  };
54 
55  template<typename R, typename C>
56  struct DecomposeMemberPtr<R (C::*)>
57  {
58  using Value_t = R;
59  using StructType_t = C;
60  };
61  }
62 
63  template<typename PtrType>
65 
66  template<typename PtrType>
68 
69  template<auto Ptr>
71 
72  template<auto Ptr>
74 }
decltype(TypeGetter(&C::operator())) TypeGetter(const C &c)
Definition: typegetter.h:30
std::decay_t< decltype(*detail::TypeGetter(*static_cast< F * >(nullptr)))> CallTypeGetter_t
Definition: typegetter.h:33
constexpr auto ArgCount_v
Definition: typegetter.h:46
typename detail::DecomposeMemberPtr< PtrType >::StructType_t MemberTypeStruct_t
Definition: typegetter.h:67
STL namespace.
MemberTypeType_t< decltype(Ptr)> MemberPtrType_t
Definition: typegetter.h:70
constexpr detail::ExprTree< detail::ExprType::LeafStaticPlaceholder, detail::MemberPtrs< Ptr > > f
Definition: oral.h:951
concept SomeInvokable
Definition: typegetter.h:37
requires(Tup1Size==Tup2Size) const expr auto ZipWith(Tup1 &&tup1
typename detail::DecomposeMemberPtr< PtrType >::Value_t MemberTypeType_t
Definition: typegetter.h:64
std::tuple_element_t< Idx+1, detail::CallTypeGetter_t< F > > ArgType_t
Definition: typegetter.h:40
MemberTypeStruct_t< decltype(Ptr)> MemberPtrStruct_t
Definition: typegetter.h:73
std::tuple_element_t< 0, detail::CallTypeGetter_t< F > > RetType_t
Definition: typegetter.h:43