Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69901 - in sandbox/enums/libs/enums: doc test test/enum_class test/enum_class/conversion test/enum_class/meta test/enum_range test/enum_range_c test/enum_set
From: vicente.botet_at_[hidden]
Date: 2011-03-12 13:54:54


Author: viboes
Date: 2011-03-12 13:54:49 EST (Sat, 12 Mar 2011)
New Revision: 69901
URL: http://svn.boost.org/trac/boost/changeset/69901

Log:
Enums: Added enum_range, enum_class, enum_range_c tests
Added:
   sandbox/enums/libs/enums/doc/FlagWaiving.pdf (contents, props changed)
   sandbox/enums/libs/enums/doc/n2347.pdf (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/conversion/explicit_conversion_from_invalid_int_fail.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/conversion/explicit_conversion_from_valid_int_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/enum_inside_union_cons.fail.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/enum_inside_union_cons.pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/inside_union_cons.fail.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/inside_union_cons.pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/inside_union_no_cons_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_range/begin.pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_range/for_each.pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_range/random_access_range_concept.pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_range_c/
   sandbox/enums/libs/enums/test/enum_range_c.pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_range_c/advance_c.pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_range_c/back.pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_range_c/begin_end.pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_range_c/distance.pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_range_c/empty.pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_range_c/front.pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_range_c/size.pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_set/constructible_from_enum.cpp (contents, props changed)
Text files modified:
   sandbox/enums/libs/enums/test/EnumClass.cpp | 58 +------------
   sandbox/enums/libs/enums/test/EnumClass.hpp | 161 ---------------------------------------
   sandbox/enums/libs/enums/test/Ex.hpp | 26 -----
   sandbox/enums/libs/enums/test/Jamfile.v2 | 27 ++++++
   sandbox/enums/libs/enums/test/enum_class/meta/pred_of_first_fail.cpp | 2
   5 files changed, 43 insertions(+), 231 deletions(-)

Added: sandbox/enums/libs/enums/doc/FlagWaiving.pdf
==============================================================================
Binary file. No diff available.

Added: sandbox/enums/libs/enums/doc/n2347.pdf
==============================================================================
Binary file. No diff available.

Modified: sandbox/enums/libs/enums/test/EnumClass.cpp
==============================================================================
--- sandbox/enums/libs/enums/test/EnumClass.cpp (original)
+++ sandbox/enums/libs/enums/test/EnumClass.cpp 2011-03-12 13:54:49 EST (Sat, 12 Mar 2011)
@@ -17,18 +17,11 @@
 #include "./EnumClass.hpp"
 #include "./f.hpp"
 #include <boost/detail/lightweight_test.hpp>
-#include <boost/enums/enum_range.hpp>
-#include <boost/range/algorithm/for_each.hpp>
+#include <boost/enums/enum_subrange_traiter.hpp>
 
 #define RUN_TIME
 #define COMPILE_TIME
 
-void p(EnumClass )
-{
-
-}
-
-
 int main() {
 
   using namespace boost;
@@ -36,7 +29,7 @@
 
   std::cout << __LINE__ << std::endl;
 
- { // The wrapper can be constructed from a valid const char* repressentation
+ { // The wrapper can be constructed from a valid const char* representation
     EnumClass e = convert_to<EnumClass>("Enum2");
     BOOST_TEST(e==EnumClass::Enum2);
   }
@@ -47,12 +40,12 @@
   }
 #endif
 #ifdef RUN_TIME2
- { // The wrapper can not be constructed from an invalid const char* repressentation
+ { // The wrapper can not be constructed from an invalid const char* representation
     EnumClass e = convert_to<EnumClass>("CHASSE");
     // ... fail
   }
 #endif
- { // The wrapper can be constructed from a valid std::string repressentation
+ { // The wrapper can be constructed from a valid std::string representation
     std::string str = "Enum2";
     EnumClass e = convert_to<EnumClass>(str);
     BOOST_TEST(e==EnumClass::Enum2);
@@ -66,7 +59,7 @@
   }
 #endif
 #ifdef RUN_TIME2
- { // The wrapper can not be constructed from an invalid std::string repressentation
+ { // The wrapper can not be constructed from an invalid std::string representation
     std::string str = "CHASSE";
     EnumClass e = convert_to<EnumClass>(str);
     // ... fail
@@ -74,48 +67,19 @@
     BOOST_TEST(strcmp(c_str(e), "EnumClass::CHASSE")==0);
   }
 #endif
- std::cout << __LINE__ << std::endl;
- { // Explicit conversion from valid int works
- EnumClass e(convert_to<EnumClass>((unsigned char)(4)));
- BOOST_TEST(e==EnumClass::Enum1);
- }
- std::cout << __LINE__ << std::endl;
- { // Explicit conversion from invalid int results in run-time error (undefined behavior)
-// EnumClass e(convert_to<EnumClass>((unsigned char)(6)));
-// BOOST_TEST(get_value(e)==(unsigned char)(6));
- }
- std::cout << __LINE__ << std::endl;
- { // Construction of the wrapper with a valid int works
- EnumClass e(convert_to<EnumClass>((unsigned char)(5)));
- BOOST_TEST(e==EnumClass::Enum2);
- }
- std::cout << __LINE__ << std::endl; { // Construction of the wrapper with an invalid ints results in run-time error (undefined behavior)
+ { // Construction of the wrapper with an invalid ints results in run-time error (undefined behavior)
 // EnumClass e(convert_to<EnumClass>((unsigned char)(6)));
-// BOOST_TEST((unsigned char)(enums::enum_type<EnumClass>::type(6))==(unsigned char)(6));
+ BOOST_TEST((unsigned char)(enums::enum_type<EnumClass>::type(6))==(unsigned char)(6));
 // BOOST_TEST(get_value(e)==(unsigned char)(6));
   }
-#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
- std::cout << __LINE__ << std::endl;
     { // The wrapper can be used in switch through the function get only :(
     EnumClass e = EnumClass::Default;
- std::cout << __LINE__ << std::endl; //EnumClass e ;
- enums::enum_type<EnumClass>::type c=get_value(e);
- std::cout << __LINE__ << std::endl;
+ enums::enum_type<EnumClass>::type c=get_value(e);
           std::cout << int(c) << std::endl;
     switch (get_value(e)) { // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       case EnumClass::Enum1:
       case EnumClass::Enum2:
       case EnumClass::Default:
- std::cout << __LINE__ << std::endl;
           std::cout << e << std::endl;
         break;
       default:
@@ -123,11 +87,5 @@
         ;
     }
   }
- std::cout << __LINE__ << std::endl;
- {
- for_each(enum_range<EnumClass>(),p);
- enum_range<EnumClass> er;
- //EnumClass e = *boost::begin(er);
- }
   return boost::report_errors();
 }

Modified: sandbox/enums/libs/enums/test/EnumClass.hpp
==============================================================================
--- sandbox/enums/libs/enums/test/EnumClass.hpp (original)
+++ sandbox/enums/libs/enums/test/EnumClass.hpp 2011-03-12 13:54:49 EST (Sat, 12 Mar 2011)
@@ -32,147 +32,13 @@
 
 #define CTOR
 
-//! This macro will be expanded to
-//~ #if defined(BOOST_ENUM_CLASS_START)
-#if 1
   BOOST_ENUM_CLASS_START(EnumClass, unsigned char) {
     Default = 3,
     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 = 3,
- 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 = 3,
- 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(type())
- {
- }
-
- 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)
-//! conversion from the underlying int.
-inline EnumClass convert_to(boost::enums::underlying_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 the native enum type.
-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
-}
-#endif // defined(BOOST_ENUM_CLASS_START)
+BOOST_ENUMS_SPECIALIZATIONS(EnumClass, unsigned char)
 
 //! conversion from c-string.
 inline EnumClass convert_to(const char* str
@@ -246,31 +112,12 @@
     {
       BOOST_STATIC_CONSTEXPR boost::enums::enum_type<EnumClass>::type value = EnumClass::Enum2;
     };
- } // namespace meta
     template <>
- struct enum_traits<EnumClass> : enum_traiter<EnumClass>
+ struct enum_traits<EnumClass>
+ : linear_enum_traiter<EnumClass>
     {
- static std::size_t pos(EnumClass e)
- {
- switch (boost::enums::get_value(e))
- {
- case EnumClass::Default: return 0;
- case EnumClass::Enum1: return 1;
- case EnumClass::Enum2: return 2;
- default: throw "bad_parameterparameter";
- }
- }
- static EnumClass val(std::size_t p)
- {
- switch (p)
- {
- case 0: return boost::convert_to<EnumClass>(EnumClass::Default);
- case 1: return boost::convert_to<EnumClass>(EnumClass::Enum1);
- case 2: return boost::convert_to<EnumClass>(EnumClass::Enum2);
- default: throw "bad_parameter";
- }
- }
     };
+ } // namespace meta
   }
 }
 

Modified: sandbox/enums/libs/enums/test/Ex.hpp
==============================================================================
--- sandbox/enums/libs/enums/test/Ex.hpp (original)
+++ sandbox/enums/libs/enums/test/Ex.hpp 2011-03-12 13:54:49 EST (Sat, 12 Mar 2011)
@@ -28,6 +28,8 @@
     Enum2
   } BOOST_ENUM_CLASS_CONS_END(EC3, int)
 
+BOOST_ENUMS_SPECIALIZATIONS(EC3, int)
+
 namespace boost {
   namespace enums {
     namespace meta {
@@ -71,31 +73,11 @@
     {
       BOOST_STATIC_CONSTEXPR boost::enums::enum_type<EC3>::type value = EC3::Enum2;
     };
- } // namespace meta
     template <>
- struct enum_traits<EC3> : enum_traiter<EC3>
+ struct enum_traits<EC3> : linear_enum_traiter<EC3>
     {
- static std::size_t pos(EC3 e)
- {
- switch (boost::enums::get_value(e))
- {
- case EC3::Enum0: return 0;
- case EC3::Enum1: return 1;
- case EC3::Enum2: return 2;
- default: throw "bad_parameter";
- }
- }
- static EC3 val(std::size_t p)
- {
- switch (p)
- {
- case 0: return boost::convert_to<EC3>(EC3::Enum0);
- case 1: return boost::convert_to<EC3>(EC3::Enum1);
- case 2: return boost::convert_to<EC3>(EC3::Enum2);
- default: throw "bad_parameter";
- }
- }
     };
+ } // namespace meta
   }
 }
 

Modified: sandbox/enums/libs/enums/test/Jamfile.v2
==============================================================================
--- sandbox/enums/libs/enums/test/Jamfile.v2 (original)
+++ sandbox/enums/libs/enums/test/Jamfile.v2 2011-03-12 13:54:49 EST (Sat, 12 Mar 2011)
@@ -43,9 +43,13 @@
         :
         [ compile enum_class/has_same_size_as_ut_pass.cpp ]
         [ compile enum_class/underlying_type_pass.cpp ]
+ [ compile enum_class/inside_union_no_cons_pass.cpp ]
+ [ compile-fail enum_class/inside_union_cons.fail.cpp ]
+ [ compile enum_class/inside_union_cons.pass.cpp ]
+ [ compile-fail enum_class/enum_inside_union_cons.fail.cpp ]
+ [ compile enum_class/enum_inside_union_cons.pass.cpp ]
 
         [ run enum_class/cons/default_to_0_pass.cpp ]
- #[ run-fail enum_class/cons/default_to_0_fail.cpp ]
         [ run enum_class/cons/from_enum_pass.cpp ]
         [ compile-fail enum_class/cons/from_int_fails.cpp ]
 
@@ -55,6 +59,8 @@
 
         [ compile-fail enum_class/conversion/implicit_conversion_to_ut_fails.cpp ]
         [ compile-fail enum_class/conversion/implicit_conversion_to_bool_fails.cpp ]
+ [ run enum_class/conversion/explicit_conversion_from_valid_int_pass.cpp ]
+ [ run enum_class/conversion/explicit_conversion_from_invalid_int_fail.cpp ]
 
         [ compile enum_class/meta/first_pass.cpp ]
         [ compile enum_class/meta/last_pass.cpp ]
@@ -91,3 +97,22 @@
         #[ run enum_set/cons/char_ptr_ctor.pass.cpp : : : : enum_set__char_ptr_ull_ctor__pass ]
         #[ run enum_set/cons/string_ctor.pass.cpp : : : : enum_set__cons_string_ctor__pass ]
   ;
+
+ test-suite "enum_range"
+ :
+ [ run enum_range/for_each.pass.cpp : : : : enum_range__for_each__pass ]
+ [ run enum_range/begin.pass.cpp : : : : enum_range__begin__pass ]
+ [ run enum_range/random_access_range_concept.pass.cpp : : : : enum_range__random_access_range_concept__pass ]
+ ;
+
+ test-suite "enum_range_c"
+ :
+ [ run enum_range_c.pass.cpp : : : : enum_range_c__pass ]
+ [ compile enum_range_c/empty.pass.cpp : : enum_range_c__empty__pass ]
+ [ compile enum_range_c/size.pass.cpp : : enum_range_c__size__pass ]
+ [ compile enum_range_c/begin_end.pass.cpp : : enum_range_c__begin_end__pass ]
+ [ compile enum_range_c/distance.pass.cpp : : enum_range_c__distance__pass ]
+ [ compile enum_range_c/advance_c.pass.cpp : : enum_range_c__advance_c__pass ]
+ [ compile enum_range_c/front.pass.cpp : : enum_range_c__front__pass ]
+ [ compile enum_range_c/back.pass.cpp : : enum_range_c__back__pass ]
+ ;

Added: sandbox/enums/libs/enums/test/enum_class/conversion/explicit_conversion_from_invalid_int_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/conversion/explicit_conversion_from_invalid_int_fail.cpp 2011-03-12 13:54:49 EST (Sat, 12 Mar 2011)
@@ -0,0 +1,25 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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;
+
+ { // Explicit conversion from invalid int results in run-time error (undefined behavior)
+ EnumClass e(boost::convert_to<EnumClass>((unsigned char)(6)));
+ BOOST_TEST((unsigned char)(get_value(e))==(unsigned char)(6));
+ }
+
+ return boost::report_errors();
+}

Added: sandbox/enums/libs/enums/test/enum_class/conversion/explicit_conversion_from_valid_int_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/conversion/explicit_conversion_from_valid_int_pass.cpp 2011-03-12 13:54:49 EST (Sat, 12 Mar 2011)
@@ -0,0 +1,25 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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;
+
+ { // Explicit conversion from valid int works
+ EnumClass e(boost::convert_to<EnumClass>((unsigned char)(4)));
+ BOOST_TEST(e==EnumClass::Enum1);
+ }
+
+ return boost::report_errors();
+}

Added: sandbox/enums/libs/enums/test/enum_class/enum_inside_union_cons.fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/enum_inside_union_cons.fail.cpp 2011-03-12 13:54:49 EST (Sat, 12 Mar 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/enums/emulation.hpp>
+
+namespace Ex {
+ BOOST_ENUM_CLASS_START(EC_Cons, int) {
+ E0 = 3,
+ E1,
+ E2
+ } BOOST_ENUM_CLASS_CONS_END(EC_Cons, int)
+}
+BOOST_ENUMS_SPECIALIZATIONS(Ex::EC_Cons, int)
+
+#if !defined(BOOST_NO_ENUM_UNRESTRICTED_UNION)
+#error "force error as not applicable as unrestricted union available"
+#else
+// The ENUM can NOT be used as member of a union as it is the case of the underlying enum.
+union U {
+ Ex::EC_Cons e;
+ int i;
+};
+#endif
+

Added: sandbox/enums/libs/enums/test/enum_class/enum_inside_union_cons.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/enum_inside_union_cons.pass.cpp 2011-03-12 13:54:49 EST (Sat, 12 Mar 2011)
@@ -0,0 +1,32 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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 <boost/enums/emulation.hpp>
+
+namespace Ex {
+ BOOST_ENUM_CLASS_START(EC_Cons, int) {
+ E0 = 3,
+ E1,
+ E2
+ } BOOST_ENUM_CLASS_CONS_END(EC_Cons, int)
+}
+BOOST_ENUMS_SPECIALIZATIONS(Ex::EC_Cons, int)
+
+#if defined(BOOST_NO_ENUM_UNRESTRICTED_UNION)
+//#warning "not applicable as unrestricted union not available"
+#else
+// The ENUM can NOT be used as member of a union as it is the case of the underlying enum.
+union U {
+ Ex::EC_Cons e;
+ int i;
+};
+#endif

Added: sandbox/enums/libs/enums/test/enum_class/inside_union_cons.fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/inside_union_cons.fail.cpp 2011-03-12 13:54:49 EST (Sat, 12 Mar 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 <boost/enums/emulation.hpp>
+
+struct C
+{
+ int i;
+ C() : i(){};
+};
+
+#if !defined(BOOST_NO_UNRESTRICTED_UNION)
+#error "force error as not applicable as unrestricted union available"
+#else
+// The ENUM can NOT be used as member of a union as it is the case of the underlying enum.
+union U {
+ C c;
+ int i;
+};
+#endif
+

Added: sandbox/enums/libs/enums/test/enum_class/inside_union_cons.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/inside_union_cons.pass.cpp 2011-03-12 13:54:49 EST (Sat, 12 Mar 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 <boost/enums/emulation.hpp>
+
+struct C
+{
+ int i;
+ C() : i(){};
+};
+
+#if defined(BOOST_NO_UNRESTRICTED_UNION)
+//#warning "not applicable as unrestricted union not available"
+#else
+// The ENUM can NOT be used as member of a union as it is the case of the underlying enum.
+union U {
+ C c;
+ int i;
+};
+#endif
+

Added: sandbox/enums/libs/enums/test/enum_class/inside_union_no_cons_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/inside_union_no_cons_pass.cpp 2011-03-12 13:54:49 EST (Sat, 12 Mar 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/enums/emulation.hpp>
+
+BOOST_ENUM_CLASS_START(EC_NoCons, int) {
+ E0 = 3,
+ E1,
+ E2
+} BOOST_ENUM_CLASS_NO_CONS_END(EC_NoCons, int)
+BOOST_ENUMS_SPECIALIZATIONS(EC_NoCons, int)
+
+// 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 {
+ EC_NoCons e;
+ int i;
+};
+
+void pass() {
+
+ U u;
+ u.e = EC_NoCons::E1;
+
+}

Modified: sandbox/enums/libs/enums/test/enum_class/meta/pred_of_first_fail.cpp
==============================================================================
--- sandbox/enums/libs/enums/test/enum_class/meta/pred_of_first_fail.cpp (original)
+++ sandbox/enums/libs/enums/test/enum_class/meta/pred_of_first_fail.cpp 2011-03-12 13:54:49 EST (Sat, 12 Mar 2011)
@@ -18,7 +18,7 @@
   using namespace boost::enums;
 
   {
- enum_type<EnumClass>::type e = meta::pred<EnumClass, EnumClass::Default>;
+ enum_type<EnumClass>::type e = meta::pred<EnumClass, EnumClass::Default>::value;
   }
 
 }

Added: sandbox/enums/libs/enums/test/enum_range/begin.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_range/begin.pass.cpp 2011-03-12 13:54:49 EST (Sat, 12 Mar 2011)
@@ -0,0 +1,39 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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>
+#include <boost/enums/enum_range.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/irange.hpp>
+
+int main() {
+
+ using namespace boost;
+ using namespace boost::enums;
+
+ BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept < enum_range<EnumClass> > ));
+ BOOST_CONCEPT_ASSERT(( ForwardRangeConcept < enum_range<EnumClass> > ));
+// BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept < iterator_range< range_detail::integer_iterator<int> > > ));
+
+
+// BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept < enum_range<EnumClass> > ));
+// BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept < enum_range<EnumClass> > ));
+
+ {
+ enum_range<EnumClass> er;
+ EnumClass e = *boost::begin(er);
+ BOOST_TEST(e==EnumClass::Default);
+ }
+ return boost::report_errors();
+}

Added: sandbox/enums/libs/enums/test/enum_range/for_each.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_range/for_each.pass.cpp 2011-03-12 13:54:49 EST (Sat, 12 Mar 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include "./EnumClass.hpp"
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/enums/enum_range.hpp>
+#include <boost/range/algorithm/for_each.hpp>
+#include <cstddef>
+
+static std::size_t cnt=0;
+void p(EnumClass )
+{
+ cnt++;
+}
+
+int main() {
+
+ using namespace boost;
+ using namespace boost::enums;
+
+
+ {
+ for_each(enum_range<EnumClass>(),p);
+ BOOST_TEST(cnt==enums::meta::size<EnumClass>::value);
+ }
+ return boost::report_errors();
+}

Added: sandbox/enums/libs/enums/test/enum_range/random_access_range_concept.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_range/random_access_range_concept.pass.cpp 2011-03-12 13:54:49 EST (Sat, 12 Mar 2011)
@@ -0,0 +1,34 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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>
+#include <boost/enums/enum_range.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/irange.hpp>
+
+int main()
+{
+
+ using namespace boost;
+ using namespace boost::enums;
+
+ BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept < enum_range<EnumClass> > ));
+ BOOST_CONCEPT_ASSERT(( ForwardRangeConcept < enum_range<EnumClass> > ));
+// BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept < iterator_range< range_detail::integer_iterator<int> > > ));
+
+
+// BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept < enum_range<EnumClass> > ));
+// BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept < enum_range<EnumClass> > ));
+
+ return boost::report_errors();
+}

Added: sandbox/enums/libs/enums/test/enum_range_c.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_range_c.pass.cpp 2011-03-12 13:54:49 EST (Sat, 12 Mar 2011)
@@ -0,0 +1,72 @@
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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.
+//
+// Based on libs/mpl/test/range_c.hpp
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/enums/mpl/enum_range_c.hpp>
+#include <boost/mpl/advance.hpp>
+#include <boost/mpl/distance.hpp>
+#include <boost/mpl/empty.hpp>
+#include <boost/mpl/size.hpp>
+#include <boost/mpl/front.hpp>
+#include <boost/mpl/back.hpp>
+#include <boost/mpl/aux_/test.hpp>
+#include "./Ex.hpp"
+#include <boost/enums/mpl/enum_c.hpp>
+
+MPL_TEST_CASE()
+{
+ typedef enum_range_c<EC3,0,0> range0;
+ typedef enum_range_c<EC3,0,1> range1;
+ typedef enum_range_c<EC3> range3;
+
+ MPL_ASSERT_RELATION( size<range0>::value, ==, 0 );
+ MPL_ASSERT_RELATION( size<range1>::value, ==, 1 );
+ MPL_ASSERT_RELATION( size<range3>::value, ==, 3 );
+
+ MPL_ASSERT(( empty<range0> ));
+ MPL_ASSERT_NOT(( empty<range1> ));
+ MPL_ASSERT_NOT(( empty<range3> ));
+
+ MPL_ASSERT(( is_same< begin<range0>::type, end<range0>::type > ));
+ MPL_ASSERT_NOT(( is_same<begin<range1>::type, end<range1>::type > ));
+ MPL_ASSERT_NOT(( is_same<begin<range3>::type, end<range3>::type > ));
+
+// MPL_ASSERT_RELATION( front<range1>::type::value, ==, EC3::Enum0 );
+// MPL_ASSERT_RELATION( back<range1>::type::value, ==, EC3::Enum0 );
+// MPL_ASSERT_RELATION( front<range3>::type::value, ==, EC3::Enum0 );
+// MPL_ASSERT_RELATION( back<range3>::type::value, ==, EC3::Enum2 );
+ MPL_ASSERT(( is_same<enum_c<EC3,front<range1>::type::value>,
+ enum_c<EC3,EC3::Enum0> > ));
+ MPL_ASSERT(( is_same< enum_c<EC3,back<range1>::type::value>,
+ enum_c<EC3,EC3::Enum0> > ));
+ MPL_ASSERT(( is_same< enum_c<EC3,front<range3>::type::value>,
+ enum_c<EC3,EC3::Enum0> > ));
+ MPL_ASSERT(( is_same< enum_c<EC3,back<range3>::type::value>,
+ enum_c<EC3,EC3::Enum2> > ));
+}
+
+MPL_TEST_CASE()
+{
+ typedef enum_range_c<EC3> r;
+ typedef begin<r>::type first;
+ typedef end<r>::type last;
+
+ MPL_ASSERT(( is_same< advance_c<first,3>::type, last > ));
+ MPL_ASSERT(( is_same< advance_c<last,-3>::type, first > ));
+
+ MPL_ASSERT_RELATION( ( mpl::distance<first,last>::value ), ==, 3 );
+
+// typedef advance_c<first,5>::type iter;
+// MPL_ASSERT_RELATION( deref<iter>::type::value, ==, 5 );
+}

Added: sandbox/enums/libs/enums/test/enum_range_c/advance_c.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_range_c/advance_c.pass.cpp 2011-03-12 13:54:49 EST (Sat, 12 Mar 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.
+//
+// Based on libs/mpl/test/range_c.hpp
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/enums/mpl/enum_range_c.hpp>
+#include <boost/mpl/begin.hpp>
+#include <boost/mpl/end.hpp>
+#include <boost/mpl/advance.hpp>
+#include <boost/mpl/aux_/test.hpp>
+#include "./Ex.hpp"
+
+
+
+MPL_TEST_CASE()
+{
+ typedef enum_range_c<EC3> r;
+ typedef begin<r>::type first;
+ typedef end<r>::type last;
+
+ MPL_ASSERT(( is_same< advance_c<first,3>::type, last > ));
+ MPL_ASSERT(( is_same< advance_c<last,-3>::type, first > ));
+
+// typedef advance_c<first,5>::type iter;
+// MPL_ASSERT_RELATION( deref<iter>::type::value, ==, 5 );
+}

Added: sandbox/enums/libs/enums/test/enum_range_c/back.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_range_c/back.pass.cpp 2011-03-12 13:54:49 EST (Sat, 12 Mar 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.
+//
+// Based on libs/mpl/test/range_c.hpp
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/enums/mpl/enum_range_c.hpp>
+#include <boost/mpl/back.hpp>
+#include <boost/mpl/aux_/test.hpp>
+#include "./Ex.hpp"
+#include <boost/enums/mpl/enum_c.hpp>
+#include <boost/type_traits/is_same.hpp>
+
+MPL_TEST_CASE()
+{
+ typedef enum_range_c<EC3,0,1> range1;
+ typedef enum_range_c<EC3> range3;
+
+// MPL_ASSERT_RELATION( back<range1>::type::value, ==, EC3::Enum0 );
+// MPL_ASSERT_RELATION( back<range3>::type::value, ==, EC3::Enum2 );
+ MPL_ASSERT(( is_same< enum_c<EC3,back<range1>::type::value>,
+ enum_c<EC3,EC3::Enum0> > ));
+ MPL_ASSERT(( is_same< enum_c<EC3,back<range3>::type::value>,
+ enum_c<EC3,EC3::Enum2> > ));
+}
+
+

Added: sandbox/enums/libs/enums/test/enum_range_c/begin_end.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_range_c/begin_end.pass.cpp 2011-03-12 13:54:49 EST (Sat, 12 Mar 2011)
@@ -0,0 +1,31 @@
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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.
+//
+// Based on libs/mpl/test/range_c.hpp
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/enums/mpl/enum_range_c.hpp>
+#include <boost/mpl/begin.hpp>
+#include <boost/mpl/end.hpp>
+#include <boost/mpl/aux_/test.hpp>
+#include "./Ex.hpp"
+
+MPL_TEST_CASE()
+{
+ typedef enum_range_c<EC3,0,0> range0;
+ typedef enum_range_c<EC3,0,1> range1;
+
+ MPL_ASSERT(( is_same< begin<range0>::type, end<range0>::type > ));
+ MPL_ASSERT_NOT(( is_same<begin<range1>::type, end<range1>::type > ));
+
+}
+

Added: sandbox/enums/libs/enums/test/enum_range_c/distance.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_range_c/distance.pass.cpp 2011-03-12 13:54:49 EST (Sat, 12 Mar 2011)
@@ -0,0 +1,32 @@
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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.
+//
+// Based on libs/mpl/test/range_c.hpp
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/enums/mpl/enum_range_c.hpp>
+#include <boost/mpl/begin.hpp>
+#include <boost/mpl/end.hpp>
+#include <boost/mpl/distance.hpp>
+#include <boost/mpl/aux_/test.hpp>
+#include "./Ex.hpp"
+
+
+MPL_TEST_CASE()
+{
+ typedef enum_range_c<EC3> r;
+ typedef begin<r>::type first;
+ typedef end<r>::type last;
+
+ MPL_ASSERT_RELATION( ( mpl::distance<first,last>::value ), ==, 3 );
+
+}

Added: sandbox/enums/libs/enums/test/enum_range_c/empty.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_range_c/empty.pass.cpp 2011-03-12 13:54:49 EST (Sat, 12 Mar 2011)
@@ -0,0 +1,28 @@
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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.
+//
+// Based on libs/mpl/test/range_c.hpp
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/enums/mpl/enum_range_c.hpp>
+#include <boost/mpl/empty.hpp>
+#include <boost/mpl/aux_/test.hpp>
+#include "./Ex.hpp"
+
+MPL_TEST_CASE()
+{
+ typedef enum_range_c<EC3,0,0> range0;
+ typedef enum_range_c<EC3,0,1> range1;
+
+ MPL_ASSERT(( empty<range0> ));
+ MPL_ASSERT_NOT(( empty<range1> ));
+}

Added: sandbox/enums/libs/enums/test/enum_range_c/front.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_range_c/front.pass.cpp 2011-03-12 13:54:49 EST (Sat, 12 Mar 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.
+//
+// Based on libs/mpl/test/range_c.hpp
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/enums/mpl/enum_range_c.hpp>
+#include <boost/mpl/front.hpp>
+#include <boost/mpl/aux_/test.hpp>
+#include "./Ex.hpp"
+#include <boost/enums/mpl/enum_c.hpp>
+#include <boost/type_traits/is_same.hpp>
+
+MPL_TEST_CASE()
+{
+ typedef enum_range_c<EC3,0,1> range1;
+
+// MPL_ASSERT_RELATION( front<range1>::type::value, ==, EC3::Enum0 );
+// MPL_ASSERT_RELATION( front<range3>::type::value, ==, EC3::Enum0 );
+ MPL_ASSERT(( is_same<enum_c<EC3,front<range1>::type::value>,
+ enum_c<EC3,EC3::Enum0> > ));
+ MPL_ASSERT(( is_same< enum_c<EC3,front<range1>::type::value>,
+ enum_c<EC3,EC3::Enum0> > ));
+}
+
+

Added: sandbox/enums/libs/enums/test/enum_range_c/size.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_range_c/size.pass.cpp 2011-03-12 13:54:49 EST (Sat, 12 Mar 2011)
@@ -0,0 +1,28 @@
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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.
+//
+// Based on libs/mpl/test/range_c.hpp
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/enums/mpl/enum_range_c.hpp>
+#include <boost/mpl/size.hpp>
+#include <boost/mpl/aux_/test.hpp>
+#include "./Ex.hpp"
+
+MPL_TEST_CASE()
+{
+ typedef enum_range_c<EC3,0,0> range0;
+ typedef enum_range_c<EC3,0,1> range1;
+
+ MPL_ASSERT_RELATION( size<range0>::value, ==, 0 );
+ MPL_ASSERT_RELATION( size<range1>::value, ==, 1 );
+}

Added: sandbox/enums/libs/enums/test/enum_set/constructible_from_enum.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_set/constructible_from_enum.cpp 2011-03-12 13:54:49 EST (Sat, 12 Mar 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;
+
+ { // Constructible from enum
+ EnumClass e(EnumClass::Enum2);
+ BOOST_TEST(e==EnumClass::Enum2);
+ }
+ { // copy constructor emulation
+ EnumClass e1=boost::convert_to<EnumClass>(EnumClass::Enum2);
+ EnumClass e2=e1;
+ BOOST_TEST(e2==EnumClass::Enum2);
+ }
+ return boost::report_errors();
+}


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