forked from standardese/cppast
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpp_template_parameter.cpp
More file actions
83 lines (68 loc) · 2.62 KB
/
Copy pathcpp_template_parameter.cpp
File metadata and controls
83 lines (68 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright (C) 2017-2018 Jonathan Müller <[email protected]>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
#include <cppast/cpp_template_parameter.hpp>
#include <cppast/cpp_entity_kind.hpp>
using namespace cppast;
const char* cppast::to_string(cpp_template_keyword kw) noexcept
{
switch (kw)
{
case cpp_template_keyword::keyword_class:
return "class";
case cpp_template_keyword::keyword_typename:
return "typename";
}
return "should not get here";
}
std::unique_ptr<cpp_template_type_parameter> cpp_template_type_parameter::build(
const cpp_entity_index& idx, cpp_entity_id id, std::string name, cpp_template_keyword kw,
bool variadic, std::unique_ptr<cpp_type> default_type)
{
std::unique_ptr<cpp_template_type_parameter> result(
new cpp_template_type_parameter(std::move(name), kw, variadic, std::move(default_type)));
idx.register_definition(std::move(id), type_safe::cref(*result));
return result;
}
cpp_entity_kind cpp_template_type_parameter::kind() noexcept
{
return cpp_entity_kind::template_type_parameter_t;
}
cpp_entity_kind cpp_template_type_parameter::do_get_entity_kind() const noexcept
{
return kind();
}
bool detail::cpp_template_parameter_ref_predicate::operator()(const cpp_entity& e)
{
return e.kind() == cpp_entity_kind::template_type_parameter_t;
}
std::unique_ptr<cpp_non_type_template_parameter> cpp_non_type_template_parameter::build(
const cpp_entity_index& idx, cpp_entity_id id, std::string name, std::unique_ptr<cpp_type> type,
bool is_variadic, std::unique_ptr<cpp_expression> default_value)
{
std::unique_ptr<cpp_non_type_template_parameter> result(
new cpp_non_type_template_parameter(std::move(name), std::move(type), is_variadic,
std::move(default_value)));
idx.register_definition(std::move(id), type_safe::cref(*result));
return result;
}
cpp_entity_kind cpp_non_type_template_parameter::kind() noexcept
{
return cpp_entity_kind::non_type_template_parameter_t;
}
cpp_entity_kind cpp_non_type_template_parameter::do_get_entity_kind() const noexcept
{
return kind();
}
bool detail::cpp_template_ref_predicate::operator()(const cpp_entity& e)
{
return is_template(e.kind()) || e.kind() == cpp_entity_kind::template_template_parameter_t;
}
cpp_entity_kind cpp_template_template_parameter::kind() noexcept
{
return cpp_entity_kind::template_template_parameter_t;
}
cpp_entity_kind cpp_template_template_parameter::do_get_entity_kind() const noexcept
{
return kind();
}