boost - Tagged unions (aka variant) in C++ with the same type multiple times -
i need create union, 2 members of union have same type, need way identify them. example in ocaml :
type = | b of int | c of float | d of float boost.variant doesn't seem support case, there known library supports ?
if want this, think best option wrap same-but-different-types struct lets boost variant visit proper one:
struct speed { float val_; }; struct darkness { float val_; }; you might able use boost_strong_typedef automatically i'm not sure it's guaranteed generate types legal use in union (although fine in variant).
Comments
Post a Comment