Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69347 - in sandbox/enums: boost boost/enums libs libs/enums libs/enums/doc libs/enums/test
From: vicente.botet_at_[hidden]
Date: 2011-02-27 14:23:16


Author: viboes
Date: 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
New Revision: 69347
URL: http://svn.boost.org/trac/boost/changeset/69347

Log:
Enums: Added initial implementation
Added:
   sandbox/enums/boost/
   sandbox/enums/boost/enums/
   sandbox/enums/boost/enums/default_value.hpp (contents, props changed)
   sandbox/enums/boost/enums/emulation.hpp (contents, props changed)
   sandbox/enums/boost/enums/enum_class_macro.hpp (contents, props changed)
   sandbox/enums/boost/enums/enum_type.hpp (contents, props changed)
   sandbox/enums/boost/enums/get_value.hpp (contents, props changed)
   sandbox/enums/boost/enums/underlying_type.hpp (contents, props changed)
   sandbox/enums/libs/
   sandbox/enums/libs/enums/
   sandbox/enums/libs/enums/doc/
   sandbox/enums/libs/enums/doc/Jamfile.v2 (contents, props changed)
   sandbox/enums/libs/enums/doc/enums.qbk (contents, props changed)
   sandbox/enums/libs/enums/doc/enums.txt (contents, props changed)
   sandbox/enums/libs/enums/index.html (contents, props changed)
   sandbox/enums/libs/enums/test/
   sandbox/enums/libs/enums/test/EnumClass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/EnumClass.hpp (contents, props changed)
   sandbox/enums/libs/enums/test/Jamfile.v2 (contents, props changed)
   sandbox/enums/libs/enums/test/comparaision_fails.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/constructible_from_enum.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/construction_from_int_fails.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/constructor_from_int_fails.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/defaults_to_enum_default.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/equal_comparable.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/f.hpp (contents, props changed)
   sandbox/enums/libs/enums/test/has_same_size_as_ut.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/implicit_conversion_to_bool_fails.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/implicit_conversion_to_ut_fails.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/not_equal_comparable.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/odr.cpp (contents, props changed)

Added: sandbox/enums/boost/enums/default_value.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/default_value.hpp 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,35 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_ENUMS_DEFAULT_VALUE_HPP
+#define BOOST_ENUMS_DEFAULT_VALUE_HPP
+
+#include <boost/config.hpp>
+
+namespace boost {
+ namespace enums {
+
+ //! build a enum class with the default value
+ template <typename EC>
+ inline EC default_value()
+ {
+#ifdef BOOST_NO_SCOPED_ENUMS
+ return EC::default_value();
+#else
+ return EC();
+#endif
+ }
+
+ }
+}
+
+#endif

Added: sandbox/enums/boost/enums/emulation.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/emulation.hpp 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,188 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_ENUMS_EMULATION_HPP
+#define BOOST_ENUMS_EMULATION_HPP
+
+#include <boost/enums/underlying_type.hpp>
+#include <boost/enums/enum_type.hpp>
+#include <boost/enums/default_value.hpp>
+#include <boost/enums/get_value.hpp>
+#include <boost/conversion/convert_to.hpp>
+#include <boost/config.hpp>
+#include <boost/preprocessor/if.hpp>
+#include <boost/preprocessor/empty.hpp>
+
+#define BOOST_NO_UNDERLYING_TYPE
+#define BOOST_ENUMS_USE_CONSTRUCTORS 1
+
+
+#if 0
+ BOOST_PP_IF(CONS, \
+ BOOST_ENUMS_DETAIL_CONSTRUCTORS(EC, UT), \
+ BOOST_PP_EMPTY \
+ )() \
+ BOOST_PP_IF(CONV, \
+ BOOST_ENUMS_DETAIL_CONVERSIONS(EC, UT), \
+ BOOST_PP_EMPTY \
+ )() \
+
+#endif
+
+#ifndef BOOST_NO_SCOPED_ENUMS
+
+ #ifdef BOOST_NO_UNDERLYING_TYPE
+
+ #define BOOST_ENUMS_DETAIL_UNDERLYING_TYPE_SPEC(EC, UT) \
+ namespace boost { \
+ namespace enums { \
+ template <> \
+ struct underlying_type<EC> \
+ { \
+ typedef UT type; \
+ }; \
+ } \
+ }
+
+ #else // BOOST_NO_UNDERLYING_TYPE
+
+ #define BOOST_ENUMS_DETAIL_UNDERLYING_TYPE_SPEC(EC, UT)
+
+ #endif // BOOST_NO_UNDERLYING_TYPE
+
+ #define BOOST_ENUM_CLASS_START(EC, UT) \
+ enum class EC : UT
+
+ #define BOOST_ENUM_TYPE_START(EC, UT) \
+ enum EC : UT
+
+ #define BOOST_ENUM_CLASS_END(EC, UT) \
+ ; \
+ BOOST_ENUMS_DETAIL_UNDERLYING_TYPE_SPEC(EC, UT)
+
+ #define BOOST_ENUM_TYPE_END(EC, UT) \
+ ; \
+ BOOST_ENUMS_DETAIL_UNDERLYING_TYPE_SPEC(EC, UT)
+
+ #define BOOST_ENUM_CLASS_CONS_END(EC, UT) \
+ ; \
+ BOOST_ENUMS_DETAIL_UNDERLYING_TYPE_SPEC(EC, UT)
+
+ #define BOOST_ENUM_TYPE_CONS_END(EC, UT) \
+ ; \
+ BOOST_ENUMS_DETAIL_UNDERLYING_TYPE_SPEC(EC, UT)
+
+#else // BOOST_NO_SCOPED_ENUMS
+
+ #define BOOST_ENUMS_DETAIL_CONSTRUCTORS(EC, UT) \
+ EC() : val_() { } \
+ EC(type v) : val_(v) { }
+
+ #define BOOST_ENUMS_DETAIL_CONSTRUCTORS_AUX() \
+ BOOST_ENUMS_DETAIL_CONSTRUCTORS(EC, UT)
+
+ #define BOOST_ENUMS_DETAIL_CONVERSIONS(EC, UT) \
+ operator UT() { return val_; }
+
+ #define BOOST_ENUMS_DETAIL_CONVERSIONS_AUX() \
+ BOOST_ENUMS_DETAIL_CONVERSIONS(EC, UT)
+
+ #define BOOST_ENUM_CLASS_START(EC, UT) \
+ class EC \
+ { \
+ public: \
+ enum type
+
+ #define BOOST_ENUM_TYPE_START(EC, UT) \
+ class EC \
+ { \
+ public: \
+ enum type
+
+ #define BOOST_ENUMS_END_1(EC, UT) \
+ ; \
+ typedef UT underlying_type; \
+ private: \
+ underlying_type val_; \
+ public:
+
+
+ #define BOOST_ENUMS_END_2(EC, UT) \
+ EC& operator =(type rhs) { \
+ val_=rhs; \
+ return *this; \
+ } \
+ static EC default_value() \
+ { \
+ EC res; \
+ res.val_=EnumClass::type(); \
+ return res; \
+ } \
+ static EC convert_to(underlying_type v) \
+ { \
+ EC res; \
+ res.val_=v; \
+ return res; \
+ } \
+ static EC convert_to(type v) \
+ { \
+ EC res; \
+ res.val_=v; \
+ return res; \
+ } \
+ type get() const \
+ { \
+ return type(val_); \
+ } \
+ friend bool operator ==(EC lhs, EC rhs) { \
+ return lhs.get()==rhs.get(); \
+ } \
+ friend bool operator ==(type lhs, EC rhs) { \
+ return lhs==rhs.get(); \
+ } \
+ friend bool operator ==(EC lhs, type rhs) { \
+ return lhs.get()==rhs; \
+ } \
+ friend bool operator !=(EC lhs, EC rhs) { \
+ return lhs.get()!=rhs.get(); \
+ } \
+ friend bool operator !=(EC lhs, type rhs) { \
+ return lhs.get()!=rhs; \
+ } \
+ friend bool operator !=(type lhs, EC rhs) { \
+ return lhs!=rhs.get(); \
+ } \
+ }; \
+
+
+ #define BOOST_ENUM_CLASS_END(EC, UT) \
+ BOOST_ENUMS_END_1(EC, UT) \
+ BOOST_ENUMS_END_2(EC, UT) \
+
+ #define BOOST_ENUM_TYPE_END(EC, UT) \
+ BOOST_ENUMS_END_1(EC, UT) \
+ BOOST_ENUMS_DETAIL_CONVERSIONS(EC, UT) \
+ BOOST_ENUMS_END_2(EC, UT) \
+
+ #define BOOST_ENUM_CLASS_CONS_END(EC, UT) \
+ BOOST_ENUMS_END_1(EC, UT) \
+ BOOST_ENUMS_DETAIL_CONSTRUCTORS(EC, UT) \
+ BOOST_ENUMS_END_2(EC, UT) \
+
+ #define BOOST_ENUM_TYPE_CONS_END(EC, UT) \
+ BOOST_ENUMS_END_1(EC, UT) \
+ BOOST_ENUMS_DETAIL_CONSTRUCTORS(EC, UT) \
+ BOOST_ENUMS_DETAIL_CONVERSIONS(EC, UT) \
+ BOOST_ENUMS_END_2(EC, UT) \
+
+#endif // BOOST_NO_SCOPED_ENUMS
+#endif

Added: sandbox/enums/boost/enums/enum_class_macro.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/enum_class_macro.hpp 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,124 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_OPAQUE_ENUM_CLASS_MACRO_HPP
+#define BOOST_OPAQUE_ENUM_CLASS_MACRO_HPP
+
+#include <boost/enums/underlying_type.hpp>
+#include <boost/enums/enum_type.hpp>
+#include <boost/enums/default_value.hpp>
+#include <boost/enums/get_value.hpp>
+#include <boost/conversion/convert_to.hpp>
+#include <boost/config.hpp>
+#include <boost/preprocessor/join.hpp>
+#include <boost/preprocessor/if.hpp>
+#include <boost/preprocessor/greater.hpp>
+#include <boost/preprocessor/empty.hpp>
+#include <boost/preprocessor/seq/enum.hpp>
+#include <boost/preprocessor/seq/elem.hpp>
+
+#define BOOST_OPAQUE_DETAIL_PAIR_TO_LITERAL(R, DATA, OPTPAIR) \
+ BOOST_PP_JOIN(BOOST_PP_SEQ_ELEM(PAIR,0),DATA) \
+ BOOST_PP_IF(BOOST_PP_GREATER(BOOST_PP_SE_SIZE(PAIR),1), \
+ = BOOST_PP_SEQ_ELEM(PAIR,1),BOOST_PP_EMPTY)
+
+#define BOOST_OPAQUE_DETAIL_OPTPAIR_TO_NAME(EC, OPTPAIR) \
+ EC::BOOST_PP_SEQ_ELEM(PAIR,0)
+
+#define BOOST_OPAQUE_DETAIL_OPTPAIR_TO_INTERNAL_NAME(OPTPAIR) \
+ EC::BOOST_PP_JOIN(BOOST_PP_SEQ_ELEM(PAIR,0),_)
+
+#define BOOST_OPAQUE_DETAIL_CONST_DECLARATION(R, EC, OPTPAIR) \
+ const EC BOOST_OPAQUE_DETAIL_OPTPAIR_TO_NAME(EC, OPTPAIR) \
+
+
+#define BOOST_OPAQUE_DETAIL_CONST_DEFINITION(R, EC, OPTPAIR) \
+ const EC BOOST_OPAQUE_DETAIL_OPTPAIR_TO_NAME(EC, OPTPAIR) \
+ = EC::convert_to( \
+ BOOST_OPAQUE_DETAIL_OPTPAIR_TO_INTERNAL_NAME(EC, OPTPAIR) \
+ ;
+
+
+#ifndef BOOST_NO_SCOPED_ENUMS
+
+#define BOOST_ENUM_CLASS(EC, UT, SEQ) \
+ enum class EC : UT { \
+ BOOST_PP_SEQ_ENUM( \
+ BOOST_PP_SEQ_FOR_EACH( \
+ BOOST_OPAQUE_DETAIL_PAIR_TO_LITERAL, \
+ BOOST_PP_EMPTY, \
+ SEQ \
+ ) \
+ ) \
+ };
+
+#else // BOOST_NO_SCOPED_ENUMS
+
+#define BOOST_ENUM_CLASS_CONSTRUCTORS(EC, UT) \
+ EC() : val_() { } \
+ EC(UT v) : val_(v) { }
+
+#define BOOST_ENUM_CLASS_EXT(EC, UT, SEQ, CONS) \
+ class EC \
+ { \
+ public: \
+ enum type { \
+ BOOST_PP_SEQ_ENUM( \
+ BOOST_PP_SEQ_FOR_EACH( \
+ BOOST_OPAQUE_DETAIL_PAIR_TO_LITERAL, \
+ BOOST_PP_EMPTY, \
+ SEQ \
+ ) \
+ ) \
+ }; \
+ typedef UT underlying_type; \
+ private: \
+ underlying_type val_; \
+ public: \
+ BOOST_PP_SEQ_FOR_EACH( \
+ BOOST_OPAQUE_DETAIL_CONST_DECLARATION, \
+ EC, \
+ SEQ \
+ ) \
+ BOOST_PP_IF(CONS, \
+ BOOST_ENUM_CLASS_CONSTRUCTORS(EC, UT), \
+ BOOST_PP_EMPTY \
+ ) \
+ static EC default_value() \
+ { \
+ EC res; \
+ res.val_=EnumClass::type(); \
+ return res; \
+ } \
+ static EC convert_to(underlying_type v) \
+ { \
+ EC res; \
+ res.val_=type(v); \
+ return res; \
+ } \
+ type get() const \
+ { \
+ return type(val_); \
+ } \
+ }; \
+ BOOST_PP_SEQ_FOR_EACH( \
+ BOOST_OPAQUE_DETAIL_CONST_DEFINITION, \
+ EC, \
+ SEQ \
+ ) \
+
+
+#define BOOST_ENUM_CLASS(EC, UT, SEQ) \
+ BOOST_ENUM_CLASS_EXT(EC, UT, SEQ, defined(BOOST_ENUMS_NO_CONSTRUCTORS))
+
+#endif // BOOST_NO_SCOPED_ENUMS
+#endif

Added: sandbox/enums/boost/enums/enum_type.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/enum_type.hpp 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,33 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_ENUMS_ENUM_TYPE_HPP
+#define BOOST_ENUMS_ENUM_TYPE_HPP
+
+#include <boost/config.hpp>
+
+namespace boost {
+ namespace enums {
+
+ template <typename EC>
+ struct enum_type
+ {
+#ifdef BOOST_NO_SCOPED_ENUMS
+ typedef typename EC::type type;
+#else
+ typedef EC type;
+#endif
+ };
+ }
+}
+
+#endif

Added: sandbox/enums/boost/enums/get_value.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/get_value.hpp 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,36 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_ENUMS_GET_VALUE_HPP
+#define BOOST_ENUMS_GET_VALUE_HPP
+
+#include <boost/config.hpp>
+#include <boost/enums/enum_type.hpp>
+
+namespace boost {
+ namespace enums {
+
+ template <typename EC>
+ inline
+ typename enum_type<EC>::type
+ get_value(EC e)
+ {
+#ifdef BOOST_NO_SCOPED_ENUMS
+ return e.get();
+#else
+ return e;
+#endif
+ }
+ }
+}
+
+#endif

Added: sandbox/enums/boost/enums/underlying_type.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/underlying_type.hpp 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,36 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_ENUMS_UNDERLYING_TYPE_HPP
+#define BOOST_ENUMS_UNDERLYING_TYPE_HPP
+
+#include <boost/config.hpp>
+#ifndef BOOST_NO_SCOPED_ENUMS
+#include <type_traits>
+#endif
+
+namespace boost {
+ namespace enums {
+ template <typename EC>
+ struct underlying_type
+ {
+#ifdef BOOST_NO_SCOPED_ENUMS
+ typedef typename EC::underlying_type type;
+#else
+ //~ typedef std::underlying_type<EC>::type type;
+#endif
+ };
+
+ }
+}
+
+#endif

Added: sandbox/enums/libs/enums/doc/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/doc/Jamfile.v2 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,62 @@
+# Boost.ENUMS library documentation Jamfile ---------------------------------
+#
+# Copyright Vicente J. Botet Escriba 2009. Use, modification and
+# distribution is subject to the Boost Software License, Version
+# 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+#
+# See http://www.boost.org for updates, documentation, and revision history.
+
+import quickbook ;
+
+xml enums : enums.qbk ;
+
+boostbook standalone
+ :
+ enums
+ :
+ # HTML options first:
+ # Use graphics not text for navigation:
+ <xsl:param>navig.graphics=1
+ # How far down we chunk nested sections, basically all of them:
+ <xsl:param>chunk.section.depth=0
+ # Don't put the first section on the same page as the TOC:
+ <xsl:param>chunk.first.sections=1
+ # How far down sections get TOC's
+ <xsl:param>toc.section.depth=4
+ # Max depth in each TOC:
+ <xsl:param>toc.max.depth=2
+ # How far down we go with TOC's
+ <xsl:param>generate.section.toc.level=10
+ # Path for links to Boost:
+ <xsl:param>boost.root=../../../..
+ # Path for libraries index:
+ <xsl:param>boost.libraries=../../../../libs/libraries.htm
+ # Use the main Boost stylesheet:
+ <xsl:param>html.stylesheet=../../../../doc/src/boostbook.css
+
+ # PDF Options:
+ # TOC Generation: this is needed for FOP-0.9 and later:
+ <xsl:param>fop1.extensions=0
+ # Or enable this if you're using XEP:
+ <xsl:param>xep.extensions=1
+ # TOC generation: this is needed for FOP 0.2, but must not be set to zero for FOP-0.9!
+ <xsl:param>fop.extensions=0
+ # No indent on body text:
+ <xsl:param>body.start.indent=0pt
+ # Margin size:
+ <xsl:param>page.margin.inner=0.5in
+ # Margin size:
+ <xsl:param>page.margin.outer=0.5in
+ # Yes, we want graphics for admonishments:
+ <xsl:param>admon.graphics=1
+ # Set this one for PDF generation *only*:
+ # default pnd graphics are awful in PDF form,
+ # better use SVG's instead:
+ <format>pdf:<xsl:param>admon.graphics.extension=".svg"
+ <format>pdf:<xsl:param>admon.graphics.path=$(boost-images)/
+ <format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/libs/enums/doc/html
+ ;
+
+install pdf-install : standalone : <location>. <install-type>PDF ;
+

Added: sandbox/enums/libs/enums/doc/enums.qbk
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/doc/enums.qbk 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,318 @@
+[/
+ / Copyright (c) 2010 Vicente J. Botet Escriba
+ /
+ / Distributed under the Boost Software License, Version 1.0. (See accompanying
+ / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ /]
+
+[article Toward Boost.Enums
+ [quickbook 1.5]
+ [version 0.1.1]
+ [authors [Botet Escriba, Vicente J.]]
+ [copyright 2010 Vicente J. Botet Escriba]
+ [id boost.enums]
+ [/dirname enums]
+ [license
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+ ]
+]
+
+[:["Strong type checking is gold;
+ normal type checking is silver;
+ and casting is brass]]
+[:[*['-- ]]]
+
+[warning Enums is not a part of the Boost libraries.]
+
+[/========================]
+[section Overview]
+[/========================]
+
+
+
+[/====================================]
+[heading How to Use This Documentation]
+[/====================================]
+
+
+This documentation makes use of the following naming and formatting conventions.
+
+* Code is in `fixed width font` and is syntax-highlighted.
+* Replaceable text that you will need to supply is in [~italics].
+* If a name refers to a free function, it is specified like this:
+ `free_function()`; that is, it is in code font and its name is followed by `()` to indicate that it is a free function.
+* If a name refers to a class template, it is specified like this: `class_template<>`; that is, it is in code font and its name is followed by `<>` to indicate that it is a class template.
+* If a name refers to a function-like macro, it is specified like this: `MACRO()`;
+ that is, it is uppercase in code font and its name is followed by `()` to indicate that it is a function-like macro. Object-like macros appear without the trailing `()`.
+* Names that refer to /concepts/ in the generic programming sense are specified in CamelCase.
+
+[note In addition, notes such as this one specify non-essential information that provides additional background or rationale.]
+
+Finally, you can mentally add the following to any code fragments in this document:
+
+ // Include all of the core Enums files
+ #include <boost/enums.hpp>
+
+ using namespace boost;
+
+[section Motivation]
+
+The David E. Miller, Herb Sutter and Bjarne Stroustrup's proposal ([@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1891.pdf [*N1891: Strongly Typed Enums (revision 3)] includes a clear motivation for "Strongly Typed Enums".
+
+On compilers not providing "Strongly Typed Enums" we can make a quite close emulation. This allows to write programs that are portable on comilers providing this feature natively and using the emulation on the others.
+
+[endsect]
+[/==================]
+[section Description]
+[/==================]
+
+
+[*Boost.Enums] intends to provide a library partial solution to this problem.
+
+[*Boost.Enums] provides:
+
+* Some language-like macros helping to define scoped enum classes.
+* Some meta-functions and functions helping to write portable programs using scoped enum classes under comilers supporting them natively or by an emulation on the others.
+
+[endsect]
+[endsect]
+
+[/==============================]
+[section:users_guide Users' Guide]
+[/==============================]
+
+[/======================================]
+[section:getting_started Getting Started]
+[/======================================]
+
+[/======================================]
+[section:install Installing Boost.Enums]
+[/======================================]
+
+[/=================================]
+[heading Getting Boost.Enums]
+[/=================================]
+
+You can get the last stable release of [*Boost.Enums] by downloading [^enums.zip] from the
+[@http://www.boostpro.com/vault/index.php?action=downloadfile&filename=enums.zip&directory=Utilities& Boost Vault Utilities directory]
+
+You can also access the latest (unstable?) state from the [@https://svn.boost.org/svn/boost/sandbox/enums Boost Sandbox].
+
+[/=================================]
+[heading Building Boost.Enums]
+[/=================================]
+
+There is no need to compile [*Boost.Enums], since it's
+a header only library. Just include your Boost header directory in your
+compiler include path.
+
+[/=========================]
+[heading Requirements]
+[/=========================]
+
+[*Boost.Enums] depends only on Boost.Conversion and Boost.Config (and all libraries they depends on).
+
+
+[/========================]
+[heading Exceptions safety]
+[/========================]
+
+All functions in the library are exception-neutral and provide strong guarantee of exception safety as long as the underlying parameters provide it.
+
+[/====================]
+[heading Thread safety]
+[/====================]
+
+All functions in the library are thread-unsafe except when noted explicitly.
+
+[/=======================]
+[heading Tested compilers]
+[/=======================]
+
+The implementation will eventually work with most C++03 conforming compilers.
+Current version has been tested on:
+
+Windows with
+
+* MSVC 10.0
+
+Cygwin 1.5 with
+
+* GCC 3.4.4
+
+Cygwin 1.7 with
+
+* GCC 4.3.4
+
+MinGW with
+
+* GCC 4.4.0
+* GCC 4.5.0
+* GCC 4.5.0 C++0x
+* GCC 4.6.0
+* GCC 4.6.0 C++0x
+
+Ubuntu 10.10
+
+* GCC 4.4.5
+* GCC 4.4.5 -std=c++0x
+* GCC 4.5.1
+* GCC 4.5.1 -std=c++0x
+* clang 2.8
+
+[note Please let us know how this works on other platforms/compilers.]
+
+[note Please send any questions, comments and bug reports to boost <at> lists <dot> boost <dot> org.]
+
+[endsect]
+[/=============================]
+[section Hello World! ]
+[/=============================]
+
+
+[endsect]
+
+[endsect]
+
+[section Tutorial]
+
+
+[endsect]
+
+[section Examples]
+[section Identifier]
+
+
+[endsect]
+[endsect]
+
+
+
+[section:ext_references External Resources]
+
+[variablelist
+[
+ [[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2347.pdf [*N2347: Strongly Typed Enums (revision 3)]]]
+ [Alisdair Meredith]
+]
+
+[
+ [[@http://www.gimpel.com/html/strong.htm [*PC-lint/FlexeLint Strong Type Checking]]]
+ [Gimpel Software]
+]
+
+
+
+]
+
+[endsect]
+
+[endsect]
+
+
+[section Reference]
+
+[/==========================================================================================]
+[section:opaque_hpp Header `<boost/enums.hpp>`]
+[/==========================================================================================]
+
+Include all the enums public header files.
+
+ #include <boost/enums/enums.hpp>
+
+[endsect]
+
+
+[/==========================================================================================]
+[section:new_class_hpp Header `<boost/enums/enums.hpp>`]
+[/==========================================================================================]
+
+
+[endsect]
+
+[endsect]
+
+[/=================]
+[section Appendices]
+[/=================]
+
+[section:history Appendix A: History]
+
+[section [*Version 0.1.1, Febraury 18, 2011] ]
+
+[*Tests:]
+
+* Test pass on Ubuntu 10.10 for
+
+* GCC 4.4.5
+* GCC 4.4.5 -std=c++0x
+* GCC 4.5.1
+* GCC 4.5.1 -std=c++0x
+* clang 2.8
+
+
+[endsect]
+
+[section [*Version 0.1.0, Mars 01, 2011] ]
+
+Initial version.
+
+[*Features:]
+
+* a
+
+[endsect]
+[endsect]
+
+[section:rationale Appendix B: Design Rationale]
+
+[heading lala]
+
+
+[endsect]
+
+[section:implementation Appendix C: Implementation Notes]
+
+
+[heading lala]
+
+
+[endsect]
+[section:acknowledgements Appendix D: Acknowledgements]
+
+Thanks to .
+
+[endsect]
+[section Appendix E: Tests]
+
+[section new_class]
+
+[table Contructors and Assignement
+ [[Name] [kind] [Description] [Result]]
+]
+
+[endsect]
+
+[endsect]
+[section Appendix F: Tickets]
+
+[endsect]
+
+[/=====================================]
+[section:todo Appendix F: Future plans]
+[/=====================================]
+
+[heading Tasks to do before review]
+
+* Complete the doc and the tests
+
+[/heading For later releases]
+
+
+
+[endsect]
+[endsect]
+
+

Added: sandbox/enums/libs/enums/doc/enums.txt
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/doc/enums.txt 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,120 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+
+SCOPED CLASS CONS EMU C++0X Feature
+NO-1 YES YES YES YES The type is named as such
+NO-1 NO-2 NO-2 NO-2 YES The enum type is named as such
+YES NO-3 NO-3 NO-3 YES is_enum<EC> is true_type
+NO-8 YES YES YES YES The wrapper has the same size as the underlying enum
+YES NO-4 YES YES YES The wrapper defaults to the enum default
+YES YES YES YES YES Construction of the wrapper from int compile fails
+YES YES YES YES YES The wrapper can be constructed from enum literals
+YES YES YES YES YES The wrapper can be compared to enum literals
+YES YES YES YES YES The wrapper can be compared
+NO-7 YES YES YES YES The wrapper is not implicit convertible to underlying int
+YES NO-5 YES YES YES The assignation of an enum class conversion from a valid int works
+YES NO-5 YES YES YES Construction of the wrapper with an enum class conversion from an valid int works
+YES YES NO-6 NO-6 YES The wrapper can be used as member of a union as it is the case of the underlying enum.
+YES NO-9 NO-9 NO-9 YES The wrapper can be used in switch
+YES NO-9 NO-9 YES YES The literals can be used in switch/case
+NO-7 YES YES YES YES The wrapper can not be used on a if (is not convertible to bool)
+NO-8 YES YES YES YES The wrapper can have an underlying type different of int.
+
+NO-1 Type name
+=============
+Scoped enums are portable only if the use of type is named BOOST_ENUM_CLASS(N)
+
+NO-2 Type name
+=============
+The access to the real enum type is portable only through the enum_type metafunction
+
+Use in templates
+================
+The wrapper can not be used in template meta-programming.
+We need to use the nested enum type and the enum class literals.
+Use enum_type<EC>::type and BOOST_ENUM_VALUE(EV)
+This meta-function will be equivalet to EC if enum class is supported
+
+NO-3 is_enum
+=======
+The wrapper is not an C++98/C++0x enum.
+We need to use the nested enum type.
+Use is_enum<enum_type<EC>::type>
+
+
+NO-4 Default value
+=============
+There is no portable way to manage with standard *implicit* default values if the enum class emmulation can not define constructors.
+I have found an explicit way that allows to assign the default value.
+Use default_value<EC>().
+This function will be equivalet to EC() if enum class is supported
+
+NO-5 Explicit conversion from int
+==========================
+There is no portable way to manage with standard *explicit* conversion of ints if the enum class emmulation can not define constructors.
+I have found an explicit way that allows to manage with explicit conversion using afunction instead of the Constructor
+Use convert_to<EC>(v)
+This function will be equivalet to EC(v) if enum class is supported
+
+NO-6 Use in union
+=================
+not possible if the compiler doesn't allos class with constructors in unions
+
+NO-7 Implicit conversion to int and bool
+=================
+As the type is a C++98 enum implicit converions to int and bool are possible
+
+NO-8 Use in union
+=================
+As the type is a C++98 enum there is no way to specify the underlying type.
+
+NO-9 Use in Switch
+=============
+As the wrapper is a class we can not use it directly in a switch.
+We need to extract the enum value, and use the enum class literals.
+Use get_value(v) and BOOST_ENUM_VALUE(EV)
+This function will be equivalet to v if enum class is supported
+This macro will be equivalet to EV if enum class is supported
+
+
+//! C++0x like extended enumeration class providing:
+//! * scoped constatnts,
+//! * conversion to the underlying int type and
+//! * conversion to/from strings.
+
+//! Equivalet to
+//! enum class EnumClass : Underlying {
+//! Default = 0,
+//! Enum1,
+//! Enum2
+//! };
+
+//! ENUM_CLASS_BEGIN(EnumClass, Underlying)
+//! Default = 0,
+//! Enum1,
+//! Enum2
+//! ENUM_CLASS_END(EnumClass, Underlying)
+
+//! PP Sequence Syntax
+//! ENUM_CLASS(EnumClass, Underlying,
+//! ( (Default) (0) )
+//! ( (Enum1) )
+//! ( (Enum2) )
+//! );
+
+//! PP Variadic Syntax
+//! ENUM_CLASS(EnumClass, (Underlying),
+//! (Default) (0),
+//! Enum1,
+//! Enum2
+//! );

Added: sandbox/enums/libs/enums/index.html
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/index.html 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,15 @@
+<html>
+<head>
+<meta http-equiv="refresh" content="0; URL=doc/html/index.html">
+</head>
+<body>
+Automatic redirection failed, please go to
+../../doc/html/enums.html
+<p>&copy; Copyright 2009-2010 Vicente J. Botet Escrib&aacute;.
+Distributed under the Boost Software
+License, Version 1.0. (See accompanying file <a href="../../LICENSE_1_0.txt">
+LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
+http://www.boost.org/LICENSE_1_0.txt>)
+</p>
+</body>
+</html>

Added: sandbox/enums/libs/enums/test/EnumClass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/EnumClass.cpp 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,109 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at
http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <cstring>
+#include <string>
+#include <iostream>
+
+#include "./EnumClass.hpp"
+#include "./f.hpp"
+#include <boost/detail/lightweight_test.hpp>
+
+#define RUN_TIME
+#define COMPILE_TIME
+
+int main() {
+
+ using namespace boost;
+ using namespace boost::enums;
+
+
+ { // The wrapper can be constructed from a valid const char* repressentation
+ EnumClass e = convert_to<EnumClass>("Enum2");
+ BOOST_TEST(e==EnumClass::Enum2);
+ }
+#ifdef COMPILE_TIME2
+ { // Construction of the wrapper from const char * compile fails
+ const char* ptr = 0;
+ EnumClass e0=ptr;
+ }
+#endif
+#ifdef RUN_TIME2
+ { // The wrapper can not be constructed from an invalid const char* repressentation
+ EnumClass e = convert_to<EnumClass>("CHASSE");
+ // ... fail
+ }
+#endif
+ { // The wrapper can be constructed from a valid std::string repressentation
+ std::string str = "Enum2";
+ EnumClass e = convert_to<EnumClass>(str);
+ BOOST_TEST(e==EnumClass::Enum2);
+ BOOST_TEST(strcmp(c_str(e),"EnumClass::Enum2")==0);
+ }
+#ifdef COMPILE_TIME2
+ { // Construction of the wrapper from const char * compile fails
+ std::string str;
+ EnumClass e0 = str;
+ }
+#endif
+#ifdef RUN_TIME2
+ { // The wrapper can not be constructed from an invalid std::string repressentation
+ std::string str = "CHASSE";
+ EnumClass e = convert_to<EnumClass>(str);
+ // ... fail
+ BOOST_TEST(e==EnumClass::Enum2);
+ BOOST_TEST(strcmp(c_str(e), "EnumClass::CHASSE")==0);
+ }
+#endif
+
+ //~ { // Explicit conversion from valid int works
+ //~ EnumClass e(convert_to<EnumClass>(u’\1);
+ //~ BOOST_TEST(e==EnumClass::Enum1);
+ //~ }
+ //~ { // Explicit conversion from invalid int works also !!!
+ //~ EnumClass e(convert_to<EnumClass>(u’\3);
+ //~ // ... fail
+ //~ }
+ //~ { // Construction of the wrapper with a valid int works
+ //~ EnumClass e(convert_to<EnumClass>(u’\2);
+ //~ BOOST_TEST(e==EnumClass::Enum2);
+ //~ }
+ //~ { // Construction of the wrapper with an invalid ints results in run-time error
+ //~ EnumClass e(convert_to<EnumClass>(u’\3);
+ //~ //BOOST_TEST(e==3);
+ //~ }
+#if !defined(CTOR) && (BOOST_ENUMS_USE_CONSTRUCTORS==0)
+ { // The wrapper can be used as member of a union as it is the case of the underlying enum (When constructors are not defined).
+ union U {
+ EnumClass e;
+ int i;
+ };
+ U u;
+ u.e = EnumClass::Enum1;
+ }
+#endif
+ { // The wrapper can be used in switch through the function get only :(
+ //~ EnumClass e = default_value<EnumClass>();
+ EnumClass e ;
+ switch (get_value(e)) { // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ case EnumClass::Enum1:
+ case EnumClass::Enum2:
+ case EnumClass::Default:
+ std::cout << e << std::endl;
+ break;
+ default:
+ std::cout << e << ":"<< get_value(e) << std::endl;
+ ;
+ }
+ }
+ return boost::report_errors();
+}

Added: sandbox/enums/libs/enums/test/EnumClass.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/EnumClass.hpp 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,215 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef ENUMCLASS_HPP
+#define ENUMCLASS_HPP
+
+
+#include <boost/enums/underlying_type.hpp>
+#include <boost/enums/enum_value.hpp>
+#include <boost/enums/enum_type.hpp>
+#include <boost/enums/default_value.hpp>
+#include <boost/enums/get_value.hpp>
+#include <boost/conversion/convert_to.hpp>
+#include <boost/enums/emulation.hpp>
+#include <cassert>
+#include <cstring>
+#include <string>
+
+#define CTOR
+
+//! This macro will be expanded to
+//~ #if defined(BOOST_ENUM_CLASS_START)
+#if 1
+ BOOST_ENUM_CLASS_START(EnumClass, unsigned char) {
+ Default = 0,
+ Enum1,
+ Enum2
+ } BOOST_ENUM_CLASS_CONS_END(EnumClass, unsigned char)
+
+#else // defined(BOOST_ENUM_CLASS_START)
+ #if !defined(BOOST_NO_SCOPED_ENUMS)
+enum class EnumClass : unsigned char
+{
+ Default = 0,
+ Enum1,
+ Enum2
+}
+;
+
+namespace boost {
+ namespace enums {
+ template <>
+ struct underlying_type<EnumClass>
+ {
+ typedef unsigned char type;
+ };
+ }}
+#else // !defined(BOOST_NO_SCOPED_ENUMS)
+
+class EnumClass {
+public:
+ //! nested C++98 enumeration class
+ enum type
+ {
+ Default = 0,
+ Enum1,
+ Enum2
+ };
+ typedef unsigned char underlying_type;
+private:
+ //! stored value with underlying type
+ underlying_type Val;
+
+public:
+ //! static helper conversion from the default enum.
+ static EnumClass default_value()
+ {
+ EnumClass res;
+ res.Val=EnumClass::type();
+ return res;
+ }
+
+ //! static helper conversion from the underlying enum. Used when constructors can not be used.
+ static EnumClass convert_to(type v)
+ {
+ EnumClass res;
+ res.Val=v;
+ return res;
+ }
+
+ //! static helper conversion from the underlying int.
+ static EnumClass convert_to(underlying_type v)
+ {
+ EnumClass res;
+ res.Val=v;
+ return res;
+ }
+
+#ifdef CTOR
+ //! default constructor :: Default
+ EnumClass() : Val()
+ {
+ }
+
+ EnumClass(type v) : Val(v)
+ {
+ }
+#endif // CTOR
+
+ EnumClass& operator =(type rhs) {
+ Val=rhs;
+ return *this;
+ }
+
+ type get() const
+ {
+ return type(Val);
+ }
+
+ friend bool operator ==(EnumClass lhs, EnumClass rhs) {
+ return lhs.get()==rhs.get();
+ }
+
+ friend bool operator ==(type lhs, EnumClass rhs) {
+ return lhs==rhs.get();
+ }
+
+ friend bool operator ==(EnumClass lhs, type rhs) {
+ return lhs.get()==rhs;
+ }
+
+ friend bool operator !=(EnumClass lhs, EnumClass rhs) {
+ return lhs.get()!=rhs.get();
+ }
+
+ friend bool operator !=(EnumClass lhs, type rhs) {
+ return lhs.get()!=rhs;
+ }
+
+ friend bool operator !=(type lhs, EnumClass rhs) {
+ return lhs!=rhs.get();
+ }
+
+};
+
+
+#endif // !defined(BOOST_NO_SCOPED_ENUMS)
+#endif // defined(BOOST_ENUM_CLASS_START)
+
+//! conversion from the underlying int.
+inline EnumClass convert_to(boost::enums::underlying_type<EnumClass>::type v
+//~ inline EnumClass convert_to(unsigned int v
+ , boost::dummy::type_tag<EnumClass> const&
+)
+{
+#ifdef BOOST_NO_SCOPED_ENUMS
+ return EnumClass::convert_to(v);
+#else
+ return EnumClass(v);
+#endif
+}
+
+//! conversion from the underlying int.
+inline EnumClass convert_to(boost::enums::enum_type<EnumClass>::type v
+ , boost::dummy::type_tag<EnumClass> const&
+)
+{
+#ifdef BOOST_NO_SCOPED_ENUMS
+ return EnumClass::convert_to(v);
+#else
+ return EnumClass(v);
+#endif
+}
+
+
+
+//! conversion from c-string.
+inline EnumClass convert_to(const char* str
+ , boost::dummy::type_tag<EnumClass> const&
+)
+{
+ if (strcmp(str, "Default") ==0) { return boost::convert_to<EnumClass>(EnumClass::Default); }
+ if (strcmp(str, "Enum1") ==0) { return boost::convert_to<EnumClass>(EnumClass::Enum1); }
+ if (strcmp(str, "Enum2") ==0) { return boost::convert_to<EnumClass>(EnumClass::Enum2); }
+ assert(false && "invalid string for ArqType");
+}
+
+//! conversion from std::string.
+inline EnumClass convert_to(const std::string& str
+ , boost::dummy::type_tag<EnumClass> const&
+)
+{
+ return boost::convert_to<EnumClass>(str.c_str());
+}
+
+//! explicit conversion to c-string.
+inline const char* c_str(EnumClass e)
+{
+ switch (boost::enums::get_value(e))
+ {
+ case BOOST_ENUM_VALUE(EnumClass::Default) : return("EnumClass::Default");
+ case BOOST_ENUM_VALUE(EnumClass::Enum1): return("EnumClass::Enum1");
+ case BOOST_ENUM_VALUE(EnumClass::Enum2) : return("EnumClass::Enum2");
+ default:
+ return("EnumClass::???");
+ }
+}
+
+//! OSTRREAM overloading
+template <typename OSTREAM>
+inline OSTREAM& operator <<(OSTREAM& os, EnumClass v) {
+ os << c_str(v);
+ return os;
+}
+
+#endif

Added: sandbox/enums/libs/enums/test/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/Jamfile.v2 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,56 @@
+# Boost Enums Library test Jamfile
+
+# Copyright Vicente Botet 2010-2011
+
+# Distributed under the Boost Software License, Version 1.0.
+# See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt
+
+# See library home page at http://www.boost.org/libs/opaque
+
+
+if ! $(BOOST_ROOT)
+{
+ BOOST_ROOT = [ modules.peek : BOOST_ROOT ] ;
+}
+
+project
+ : requirements
+
+ # uncomment the line above if you build outside a Boost release
+ #<include>$(BOOST_ROOT)
+
+ <define>BOOST_ENABLE_WARNINGS
+ <warnings>all
+ <toolset>gcc:<cxxflags>-Wextra
+ <toolset>gcc:<cxxflags>-pedantic
+ <toolset>gcc:<cxxflags>-Wno-long-long
+ <toolset>darwin:<cxxflags>-Wextra
+ <toolset>darwin:<cxxflags>-pedantic
+ <toolset>darwin:<cxxflags>-Wno-long-long
+ #<toolset>pathscale:<cxxflags>-Wextra
+ <toolset>pathscale:<cxxflags>-Wno-long-long
+ <toolset>pathscale:<cxxflags>-pedantic
+ <toolset>clang:<cxxflags>-Wextra
+ <toolset>clang:<cxxflags>-pedantic
+ <toolset>clang:<cxxflags>-Wno-long-long
+ <toolset>gcc-mingw-4.5.0:<cxxflags>-Wno-missing-field-initializers
+ <toolset>gcc-mingw-4.5.0:<cxxflags>-fdiagnostics-show-option
+ <toolset>msvc:<cxxflags>/wd4127
+ ;
+
+ test-suite "examples"
+ :
+ [ compile-fail construction_from_int_fails.cpp ]
+ [ compile-fail comparaision_fails.cpp ]
+ [ compile-fail implicit_conversion_to_ut_fails.cpp ]
+ [ compile-fail implicit_conversion_to_bool_fails.cpp ]
+
+ [ compile has_same_size_as_ut.cpp ]
+ [ run defaults_to_enum_default.cpp ]
+ [ run constructible_from_enum.cpp ]
+ [ run equal_comparable.cpp ]
+ [ run not_equal_comparable.cpp ]
+ #[ run EnumClass.cpp ]
+ #[ run EnumClass.cpp ]
+ [ run EnumClass.cpp odr.cpp ]
+ ;

Added: sandbox/enums/libs/enums/test/comparaision_fails.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/comparaision_fails.cpp 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,30 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include "./EnumClass.hpp"
+
+void fail() {
+
+ { // The wrapper can be compared
+ EnumClass e0;
+ e0= EnumClass::Default;
+ BOOST_TEST(e0 < EnumClass::Enum2);
+ }
+ { // The wrapper can be compared
+ EnumClass e0;
+ e0= EnumClass::Default;
+ EnumClass e1;
+ e1= EnumClass::Enum2;
+ BOOST_TEST(e0 < e1);
+ }
+
+}

Added: sandbox/enums/libs/enums/test/constructible_from_enum.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/constructible_from_enum.cpp 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,24 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include "./EnumClass.hpp"
+#include <boost/detail/lightweight_test.hpp>
+
+int main() {
+ using namespace boost::enums;
+
+ { // Constructible from enum
+ EnumClass e(EnumClass::Enum2);
+ }
+
+ return boost::report_errors();
+}

Added: sandbox/enums/libs/enums/test/construction_from_int_fails.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/construction_from_int_fails.cpp 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,20 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include "./EnumClass.hpp"
+
+void fail() {
+
+ // Construction from int compile fails
+ EnumClass e(0);
+
+}

Added: sandbox/enums/libs/enums/test/constructor_from_int_fails.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/constructor_from_int_fails.cpp 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,20 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include "./EnumClass.hpp"
+
+void fail() {
+
+ // Construction from int compile fails
+ EnumClass e(0);
+
+}

Added: sandbox/enums/libs/enums/test/defaults_to_enum_default.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/defaults_to_enum_default.cpp 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,29 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include "./EnumClass.hpp"
+#include <boost/detail/lightweight_test.hpp>
+
+int main() {
+ using namespace boost::enums;
+
+ { // defaults to the enum default
+ EnumClass e =EnumClass() ;
+ BOOST_TEST(e==EnumClass::Default);
+ }
+ { // defaults to the enum default
+ EnumClass e = default_value<EnumClass>();
+ BOOST_TEST(e==EnumClass::Default);
+ }
+ return boost::report_errors();
+
+}

Added: sandbox/enums/libs/enums/test/equal_comparable.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/equal_comparable.cpp 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,26 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include "./EnumClass.hpp"
+#include <boost/detail/lightweight_test.hpp>
+
+int main() {
+ using namespace boost::enums;
+
+ { // equal comparable
+ EnumClass e;
+ e = EnumClass::Enum2;
+ BOOST_TEST(e==EnumClass::Enum2);
+ }
+
+ return boost::report_errors();
+}

Added: sandbox/enums/libs/enums/test/f.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/f.hpp 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1 @@
+void f(int i);

Added: sandbox/enums/libs/enums/test/has_same_size_as_ut.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/has_same_size_as_ut.cpp 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,23 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include "./EnumClass.hpp"
+#include <boost/static_assert.hpp>
+
+void pass() {
+ using namespace boost::enums;
+
+ { // has the same size as the underlying type
+ BOOST_STATIC_ASSERT(sizeof(EnumClass)==sizeof(underlying_type<EnumClass>::type));
+ }
+
+}

Added: sandbox/enums/libs/enums/test/implicit_conversion_to_bool_fails.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/implicit_conversion_to_bool_fails.cpp 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,24 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include "./EnumClass.hpp"
+
+void fail() {
+
+ { // The wrapper can be used on a if (is not convertible to bool)
+ EnumClass e;
+ bool b = e; // error
+ if (e) // error
+ b=false;
+ }
+
+}

Added: sandbox/enums/libs/enums/test/implicit_conversion_to_ut_fails.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/implicit_conversion_to_ut_fails.cpp 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,26 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include "./EnumClass.hpp"
+
+void f(int ) {
+}
+
+void fail() {
+
+ { // The wrapper is not implicit convertible to underlying int
+ EnumClass e ;
+ f(e); // error
+ int i = e; // error
+ }
+
+}

Added: sandbox/enums/libs/enums/test/not_equal_comparable.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/not_equal_comparable.cpp 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,26 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include "./EnumClass.hpp"
+#include <boost/detail/lightweight_test.hpp>
+
+int main() {
+ using namespace boost::enums;
+
+ { // not equal comparable
+ EnumClass e;
+ e = EnumClass::Enum2;
+ BOOST_TEST(e!=EnumClass::Default);
+ }
+
+ return boost::report_errors();
+}

Added: sandbox/enums/libs/enums/test/odr.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/odr.cpp 2011-02-27 14:23:02 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,11 @@
+#include <cassert>
+#include <cstring>
+#include <string>
+#include <iostream>
+
+#include "./EnumClass.hpp"
+
+
+void f(int ) {
+}
+


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk