DocWire SDK
DocWire SDK: Award-winning modern data processing in C++20. SourceForge Community Choice & Microsoft support. AI-driven processing. Supports nearly 100 data formats, including email boxes and OCR. Boost efficiency in text extraction, web data extraction, data mining, document analysis. Offline processing possible for security and confidentiality
invocation_traits.h
1 /*********************************************************************************************************************************************/
2 /* DocWire SDK: Award-winning modern data processing in C++20. SourceForge Community Choice & Microsoft support. AI-driven processing. */
3 /* Supports nearly 100 data formats, including email boxes and OCR. Boost efficiency in text extraction, web data extraction, data mining, */
4 /* document analysis. Offline processing possible for security and confidentiality */
5 /* */
6 /* Copyright (c) SILVERCODERS Ltd, http://silvercoders.com */
7 /* Project homepage: https://github.com/docwire/docwire */
8 /* */
9 /* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-DocWire-Commercial */
10 /*********************************************************************************************************************************************/
11 
12 #ifndef DOCWIRE_INVOCATION_TRAITS_H
13 #define DOCWIRE_INVOCATION_TRAITS_H
14 
15 #include <boost/callable_traits/args.hpp>
16 #include <boost/callable_traits/return_type.hpp>
17 #include <tuple>
18 
26 {
27 
47 template <typename T>
48 struct args
49 {
50 
53  template <typename F>
54  struct args_impl
55  {
56  using type = boost::callable_traits::args_t<F>;
57  };
58 
59  template <typename F>
60  requires requires { typename F::invocation_args_t; }
61  struct args_impl<F>
62  {
63  using type = typename F::invocation_args_t;
64  };
65 
74  using type = typename args_impl<T>::type;
75 };
76 
90 template <typename T>
91 using args_t = typename args<T>::type;
92 
93 template <typename T>
94 inline constexpr std::size_t arity_v = std::tuple_size_v<args_t<T>>;
95 
114 template <typename T>
115 struct result
116 {
117 
120  template <typename F>
121  struct result_impl
122  {
123  using type = boost::callable_traits::return_type_t<F>;
124  };
125 
126  template <typename F>
127  requires requires { typename F::invocation_result_t; }
128  struct result_impl<F>
129  {
130  using type = typename F::invocation_result_t;
131  };
132 
141  using type = typename result_impl<T>::type;
142 };
143 
157 template <typename T>
158 using result_t = typename result<T>::type;
159 
177 template <typename T>
179 {
185  static constexpr bool value =
186  requires { typename boost::callable_traits::args_t<T>; } ||
187  requires { typename std::decay_t<T>::invocation_args_t; };
188 };
189 
210 template <typename T>
211 inline constexpr bool is_invocable_v = is_invocable<T>::value;
212 
213 } // namespace docwire::invocation_traits
214 
215 #endif //DOCWIRE_INVOCATION_TRAITS_H
Provides traits classes for working with callable objects.
typename result< T >::type result_t
Type alias for the type member of the result struct.
typename args< T >::type args_t
Type alias for the type member of the args struct.
constexpr bool is_invocable_v
Variable template alias for the value of the is_invocable trait.
requires(!string_method_equipped< T >) struct stringifier< T >
Specialization for types that are streamable to std::ostream.
Extracts the argument types of a callable object.
typename args_impl< T >::type type
Type of the arguments of the callable object.
Trait that checks if a type is invocable.
static constexpr bool value
Whether the type is invocable.
Extracts the result type of a callable object.
typename result_impl< T >::type type
Type of the result of the callable object.