mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-28 17:34:53 +01:00
Migrate Value to std::variant (#635)
Also: - Switch data members, and associated parameters and return types to be values/references rather than pointers, where applicable. - Move Expression's TagVisitor to anonymous namespace, to avoid name collision. - Switch to trailing return syntax (per style guide).
This commit is contained in:
@@ -8,6 +8,21 @@
|
||||
|
||||
namespace Carbon {
|
||||
|
||||
namespace {
|
||||
|
||||
struct TagVisitor {
|
||||
template <typename Alternative>
|
||||
auto operator()(const Alternative&) -> ExpressionKind {
|
||||
return Alternative::Kind;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
auto Expression::tag() const -> ExpressionKind {
|
||||
return std::visit(TagVisitor(), value);
|
||||
}
|
||||
|
||||
auto Expression::GetIdentifierExpression() const
|
||||
-> const IdentifierExpression& {
|
||||
return std::get<IdentifierExpression>(value);
|
||||
|
||||
Reference in New Issue
Block a user