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:
Geoff Romer
2021-07-12 11:24:30 -07:00
committed by GitHub
parent ffcdaf9aff
commit de05711966
6 changed files with 316 additions and 296 deletions
+15
View File
@@ -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);