lib/cpp: optimizing Variant