forked from standardese/cppast
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpp_decltype_type.hpp
More file actions
60 lines (49 loc) · 1.7 KB
/
Copy pathcpp_decltype_type.hpp
File metadata and controls
60 lines (49 loc) · 1.7 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
// 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.
#ifndef CPPAST_CPP_DECLTYPE_TYPE_HPP_INCLUDED
#define CPPAST_CPP_DECLTYPE_TYPE_HPP_INCLUDED
#include <cppast/cpp_expression.hpp>
#include <cppast/cpp_type.hpp>
namespace cppast
{
/// A [cppast::cpp_type]() that isn't given but taken from an expression.
class cpp_decltype_type final : public cpp_type
{
public:
/// \returns A newly created `decltype` type.
static std::unique_ptr<cpp_decltype_type> build(std::unique_ptr<cpp_expression> expr)
{
return std::unique_ptr<cpp_decltype_type>(new cpp_decltype_type(std::move(expr)));
}
/// \returns A reference to the expression given.
const cpp_expression& expression() const noexcept
{
return *expr_;
}
private:
cpp_decltype_type(std::unique_ptr<cpp_expression> expr) : expr_(std::move(expr)) {}
cpp_type_kind do_get_kind() const noexcept override
{
return cpp_type_kind::decltype_t;
}
std::unique_ptr<cpp_expression> expr_;
};
/// A [cppast::cpp_type]() that isn't given but deduced using the `decltype` rules.
class cpp_decltype_auto_type final : public cpp_type
{
public:
/// \returns A newly created `auto` type.
static std::unique_ptr<cpp_decltype_auto_type> build()
{
return std::unique_ptr<cpp_decltype_auto_type>(new cpp_decltype_auto_type);
}
private:
cpp_decltype_auto_type() = default;
cpp_type_kind do_get_kind() const noexcept override
{
return cpp_type_kind::decltype_auto_t;
}
};
} // namespace cppast
#endif // CPPAST_CPP_DECLTYPE_TYPE_HPP_INCLUDED