Boost logo

Boost :

From: Eric Friedman (ebf_at_[hidden])
Date: 2002-06-20 22:49:18


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<http://groups.yahoo.com/group/boost/files/variant.zip>).

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 acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk