Malloy
Loading...
Searching...
No Matches
type_traits.hpp
1#pragma once
2
3#include "../core/http/response.hpp"
4#include "../core/http/type_traits.hpp"
5#include "../core/type_traits.hpp"
6
7#include <concepts>
8#include <variant>
9
10namespace malloy::client::concepts
11{
12
13 namespace detail
14 {
15
16 template<typename F>
18 {
19 template<malloy::http::concepts::body T>
20 void operator()(T&&)
21 {
22 F f2;
23 typename F::header_type h2;
24 typename std::decay_t<T>::value_type r;
25 f2.setup_body(h2, r);
26 }
27 };
28
37 template<typename Callback>
39 {
40 Callback cb;
41
42 template<typename V>
43 void operator()(V&&)
44 {
45 using body_t = std::decay_t<V>;
47
48 cb(std::move(res));
49 }
50
51 };
52
53 } // namespace detail
54
55 template<typename F>
56 concept response_filter = std::move_constructible<F> && requires(const F& f, const typename F::header_type& h)
57 {
58 {
59 f.body_for(h)
61
62 {
63 std::visit(detail::response_filter_body_helper<F>{}, f.body_for(h))
64 };
65 };
66
67 template<typename F, typename Filter>
68 concept http_callback = response_filter<Filter>&& std::move_constructible<F>&& requires(F cb, const Filter& f, const typename Filter::header_type& h)
69 {
70 std::visit(detail::http_cb_helper<F>{std::move(cb)}, f.body_for(h));
71 };
72
73}
74
Definition: response.hpp:22
Definition: type_traits.hpp:68
Definition: type_traits.hpp:56
Definition: type_traits.hpp:123
Helper for http_callback concept.
Definition: type_traits.hpp:39