-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathcpp_template_param.h
More file actions
67 lines (51 loc) · 1.52 KB
/
Copy pathcpp_template_param.h
File metadata and controls
67 lines (51 loc) · 1.52 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
// Copyright (C) 2022 Satya Das and CppParser contributors
// SPDX-License-Identifier: MIT
#ifndef A6947342_A917_4B84_B327_5878ACC690B3
#define A6947342_A917_4B84_B327_5878ACC690B3
#include "cppast/defs.h"
#include <memory>
#include <optional>
#include <string>
#include <variant>
namespace cppast {
class CppEntity;
class CppVarType;
class CppFunctionPointer;
class CppExpression;
/**
* Parameter types that are used to define a templated C++ entity.
*/
class CppTemplateParam
{
public:
using ParamType = std::variant<std::unique_ptr<CppVarType>, std::unique_ptr<CppFunctionPointer>>;
using ArgType = std::variant<std::unique_ptr<CppVarType>, std::unique_ptr<CppExpression>>;
public:
CppTemplateParam(std::string paramName, ArgType defArg = ArgType());
CppTemplateParam(ParamType paramType, std::string paramName, ArgType defArg = ArgType());
CppTemplateParam(CppTemplateParam&& rval) = default;
~CppTemplateParam();
public:
const std::optional<ParamType>& paramType() const
{
return paramType_;
}
const std::string& paramName() const
{
return paramName_;
}
const ArgType& defaultArg() const
{
return defaultArg_;
}
private:
// If initialized then template param is not of type typename/class
std::optional<ParamType> paramType_;
std::string paramName_;
ArgType defaultArg_;
};
} // namespace cppast
#include "cppast/cpp_expression.h"
#include "cppast/cpp_function.h"
#include "cppast/cpp_var_type.h"
#endif /* A6947342_A917_4B84_B327_5878ACC690B3 */