Instantiator
Generate c++ template instantiations
Loading...
Searching...
No Matches
Template.hpp
Go to the documentation of this file.
1#ifndef TEMPLATE_HPP_
2#define TEMPLATE_HPP_
3#include <string>
4#include <vector>
5
6#include "clang/AST/DeclCXX.h"
7#include "clang/AST/Type.h"
8
9#include "Injection.hpp"
10#include "Param.hpp"
11#include "TemplateArgument.hpp"
12
18{
19 typedef std::string StringType;
25
32
38
45 std::vector<Param> params;
46
53 std::vector<Instantiator::TemplateArgument> class_Targs;
54
56 bool is_const = false;
57
59 bool is_member = false;
60
65 bool is_constructor = false;
66
75 bool isTemplateFor(const Injection& candidate) const;
76
91 static Template createFromMFS(const clang::CXXMethodDecl* MFS, clang::PrintingPolicy pp);
92
105 static Template createFromFS(const clang::FunctionDecl* FS, clang::PrintingPolicy pp);
106};
107
108template <>
109class fmt::formatter<Template>
110{
111public:
112 constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
113 template <typename Context>
114 constexpr auto format(Template const& t, Context& ctx) const
115 {
116 return fmt::format_to(
117 ctx.out(), "{}{}<{}>::{}({}) {}", t.nested_namespace, t.class_name, t.class_Targs, t.func_name, t.params, t.is_const ? "const" : "");
118 }
119};
120
121#endif
constexpr auto parse(format_parse_context &ctx)
Definition Template.hpp:112
constexpr auto format(Template const &t, Context &ctx) const
Definition Template.hpp:114
Struct for the collection of all relevant data for a template instantiation which needs to be inserte...
Definition Injection.hpp:21
Struct for the collection of all relevant data for a template function which can provide a definition...
Definition Template.hpp:18
bool is_constructor
Definition Template.hpp:65
bool is_member
Definition Template.hpp:59
bool isTemplateFor(const Injection &candidate) const
Definition Template.cpp:82
StringType nested_namespace
Definition Template.hpp:31
StringType func_name
Definition Template.hpp:24
std::string StringType
Definition Template.hpp:19
StringType class_name
Definition Template.hpp:37
static Template createFromFS(const clang::FunctionDecl *FS, clang::PrintingPolicy pp)
Definition Template.cpp:18
bool is_const
Definition Template.hpp:56
std::vector< Param > params
Definition Template.hpp:45
static Template createFromMFS(const clang::CXXMethodDecl *MFS, clang::PrintingPolicy pp)
Definition Template.cpp:33
std::vector< Instantiator::TemplateArgument > class_Targs
Definition Template.hpp:53