mimic++ v9.2.1
Loading...
Searching...
No Matches
Signature.hpp
Go to the documentation of this file.
1// Copyright Dominic (DNKpp) Koepke 2024 - 2025.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at
4// https://www.boost.org/LICENSE_1_0.txt)
5
6#ifndef MIMICPP_PRINTING_TYPE_SIGNATURE_HPP
7#define MIMICPP_PRINTING_TYPE_SIGNATURE_HPP
8
9#pragma once
10
11#include "mimic++/Fwd.hpp"
19
20#ifndef MIMICPP_DETAIL_IS_MODULE
21 #include <algorithm>
22 #include <functional>
23 #include <iterator>
24 #include <type_traits>
25#endif
26
27namespace mimicpp::printing::type::detail
28{
29 template <print_iterator OutIter, typename... Ts>
30 constexpr OutIter print_separated(OutIter out, StringViewT const separator, util::type_list<Ts...> const ts)
31 {
32 if constexpr (0u < sizeof...(Ts))
33 {
34 std::invoke(
35 [&]<typename First, typename... Others>([[maybe_unused]] util::type_list<First, Others...> const) {
36 out = mimicpp::print_type<First>(std::move(out));
37 ((out = mimicpp::print_type<Others>(std::ranges::copy(separator, std::move(out)).out)), ...);
38 },
39 ts);
40 }
41
42 return out;
43 }
44
45 template <util::satisfies<std::is_function> Signature>
46 struct signature_type_printer<Signature>
47 {
48 template <print_iterator OutIter>
49 static OutIter print(OutIter out)
50 {
52 out = format::format_to(std::move(out), "(");
53 out = print_separated(out, ", ", signature_param_list_t<Signature>{});
54 out = format::format_to(std::move(out), ")");
55
57 {
58 out = format::format_to(std::move(out), " const");
59 }
60
62 {
63 out = format::format_to(std::move(out), " &");
64 }
66 {
67 out = format::format_to(std::move(out), " &&");
68 }
69
71 {
72 out = format::format_to(std::move(out), " noexcept");
73 }
74
75 return out;
76 }
77 };
78}
79
80#endif
constexpr printing::PrintFn print
Functional object, converting the given object to its textual representation.
Definition Print.hpp:183
constexpr printing::PrintTypeFn< T > print_type
Functional object, converting the given type to its textual representation.
Definition PrintType.hpp:478
constexpr Constness signature_const_qualification_v
Convenience constant, exposing the value member of the actual type-trait.
Definition Fwd.hpp:246
constexpr bool signature_is_noexcept_v
Convenience constant, exposing the value member of the actual type-trait.
Definition Fwd.hpp:86
typename signature_param_list< Signature >::type signature_param_list_t
Convenience alias, exposing the type member alias of the actual type-trait.
Definition Fwd.hpp:294
constexpr ValueCategory signature_ref_qualification_v
Convenience constant, exposing the value member of the actual type-trait.
Definition Fwd.hpp:262
@ lvalue
Definition Fwd.hpp:35
@ rvalue
Definition Fwd.hpp:36
@ as_const
Definition Fwd.hpp:29
std::basic_string_view< CharT, CharTraitsT > StringViewT
Definition Fwd.hpp:392