A part of the Standard Library (C++).

std::variant is a discriminating C++ union; a union that tracks the “active” member.

#include <string>
#include <variant>

struct Entry {
  std::string name;
  std::variant<std::string, int, double> value;
};

int main() {
  Entry e;
  e.name = "foo";
  e.value = 14;

  if (std::holds_alternative<std::string>(e.value)) {
    return 0;
  }

  if (std::holds_alternative<double>(e.value)) {
    return 1;
  }

  if (std::holds_alternative<int>(e.value)) {
    return 2;
  }
}