Instantiator
Generate c++ template instantiations
Loading...
Searching...
No Matches
TemplateArgument.hpp
Go to the documentation of this file.
1#ifndef INSTANTIATOR_TEMPLATE_ARGUMENT_H_
2#define INSTANTIATOR_TEMPLATE_ARGUMENT_H_
3
4#include <clang/AST/TemplateBase.h>
5#include <string>
6
7#include "fmt/color.h"
8#include "fmt/core.h"
9
10#include "clang/AST/PrettyPrinter.h"
11
12namespace Instantiator {
13
14enum class Kind
15{
16 Type,
17 NonType,
19 Pack
20};
21
26{
29
31 std::vector<std::string> names = {""};
32
33 std::string name(const std::string& sep = " ") const;
34
36 bool is_dependent = false;
37
43 static TemplateArgument createFromTemplateArgument(const clang::TemplateArgument* parm, clang::PrintingPolicy pp);
44
48 bool compare(const TemplateArgument& other) const;
49
50 inline bool operator==(const TemplateArgument& other) const { return this->compare(other); }
51};
52
53} // namespace Instantiator
54
55template <>
56class fmt::formatter<Instantiator::TemplateArgument>
57{
58public:
59 constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
60 template <typename Context>
61 constexpr auto format(Instantiator::TemplateArgument const& p, Context& ctx) const
62 {
63 return fmt::format_to(ctx.out(), "{}", p.is_dependent ? "dependent" : p.name());
64 }
65};
66
67#endif
constexpr auto format(Instantiator::TemplateArgument const &p, Context &ctx) const
constexpr auto parse(format_parse_context &ctx)
Struct for the collection of all relevant data for a function parameter.
std::vector< std::string > names
static TemplateArgument createFromTemplateArgument(const clang::TemplateArgument *parm, clang::PrintingPolicy pp)
bool operator==(const TemplateArgument &other) const
std::string name(const std::string &sep=" ") const
bool compare(const TemplateArgument &other) const