Use a lambda for tag's visit (#645)

Also shifts declaration order a little for [style](https://google.github.io/styleguide/cppguide.html#Declaration_Order); moving line_num down (data members after methods) and tag() down (factory functions before instance members).
This commit is contained in:
Jon Meow
2021-07-13 13:53:48 -07:00
committed by GitHub
parent 05c2e610ba
commit b03d3cdbb0
6 changed files with 14 additions and 50 deletions
+4 -2
View File
@@ -163,8 +163,6 @@ struct ContinuationValue {
};
struct Value {
auto tag() const -> ValKind;
// Constructors
// Return a first-class continuation represented by the
@@ -216,6 +214,10 @@ struct Value {
auto GetChoiceType() const -> const ChoiceType&;
auto GetContinuationValue() const -> const ContinuationValue&;
inline auto tag() const -> ValKind {
return std::visit([](const auto& t) { return t.Kind; }, value);
}
private:
std::variant<IntValue, FunctionValue, PointerValue, BoolValue, StructValue,
AlternativeValue, TupleValue, IntType, BoolType, TypeType,