Boost logo

Boost :

From: Eric Friedman (ebf_at_[hidden])
Date: 2002-06-24 17:02:48

Despite having received no feedback <g>, I continued to work on my
boost::variant implementation over the weekend. The product of my labors
is a variant that has been tested successfully with GCC 2.9.5 and MSVC

The new version is available at -- I've renamed
the old one.

I would really appreciate if I could get feedback (public or private) on
this work; I think it addresses most of the issues raised by the Boost
community in the "Proposal --- A type-safe union" thread that bounced
around a few weeks ago. I am aware that my implementation lacks support
for recursive types, and I intend to address this issue next.


> -----Original Message-----
> From: Eric Friedman [mailto:ebf_at_[hidden]]
> Sent: Thursday, June 20, 2002 10:49 PM
> To: Boost Mailing List
> Subject: [boost] Variant (aka Discriminated Union) implementation
> Based on some initial code and inspiration from Andrei
> Alexandrescu and
> a fair share of work of my own, I have posted an implementation of a
> variant (or discriminated union) type to the Boost Yahoo!Groups files
> section (available
> at<>).
> The best way to understand the code is to let it speak for itself (at
> least until I write documentation), but I have tried to implement most

> of the important features, including:
> * efficient stack-based allocation
> * proper handling of alignment
> * visitation (strict and non-strict) -- note as well that I have
> provided visitation factored out from the variant type (that is, it
> can be used in other libraries)
> * conversion between variant types
> * leveraging of existing Boost code, including the preprocessor
> library, the type traits library, and the mpl_v2 version of Aleksey
> Gurtoyov's MPL (which I hope will become a Boost library in the near
> future -- also note that I've included minor patches to MPL).
> As a disclaimer, the implementation has only been tested under MSVC7.
> (An initial attempt to compile with mingw-gcc exploded in my face, but

> I tend to think this may be a problem with MPL under gcc. Still
> investigating this one....) As well, my test file is rather
> rudimentary
> and is more of a proof-of-concept to myself than a robust set
> of tests.
> Let me know what you think.
> Eric Friedman
> ebf_at_[hidden]

Boost list run by bdawes at, gregod at, cpdaniel at, john at