morganstanley / hobbes

A language and an embedded JIT compiler
http://hobbes.readthedocs.io/
Apache License 2.0
1.16k stars 105 forks source link

Accessing hobbes::variant by type or by tag depends upon its number of occurrences in variant #419

Closed mo-xiaoming closed 2 years ago

mo-xiaoming commented 2 years ago

If T has no duplications, then only hobbes::variant::get<T> gets instantiated, maintaining its previous behavior and performance If T has more than one occurrence in variant, then only hobbes::variant::visit(tag) gets instantiated, it has runtime overhead compares to get, but it gives correct result