Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r70532 - in sandbox/enums/libs/enums/test: . enum_class enum_range
From: vicente.botet_at_[hidden]
Date: 2011-03-24 19:55:09


Author: viboes
Date: 2011-03-24 19:55:07 EDT (Thu, 24 Mar 2011)
New Revision: 70532
URL: http://svn.boost.org/trac/boost/changeset/70532

Log:
Enums:
Text files modified:
   sandbox/enums/libs/enums/test/EnumType.hpp | 3
   sandbox/enums/libs/enums/test/Ex.hpp | 41 +++++++++++++++
   sandbox/enums/libs/enums/test/ExType.hpp | 11 +++
   sandbox/enums/libs/enums/test/enum_class/enum_inside_union_cons.pass.cpp | 103 +++++++++++++++++++++++++++++----------
   sandbox/enums/libs/enums/test/enum_range/random_access_range_concept.pass.cpp | 2
   sandbox/enums/libs/enums/test/f.hpp | 1
   6 files changed, 130 insertions(+), 31 deletions(-)

Modified: sandbox/enums/libs/enums/test/EnumType.hpp
==============================================================================
--- sandbox/enums/libs/enums/test/EnumType.hpp (original)
+++ sandbox/enums/libs/enums/test/EnumType.hpp 2011-03-24 19:55:07 EDT (Thu, 24 Mar 2011)
@@ -29,6 +29,7 @@
 #include <cassert>
 #include <cstring>
 #include <string>
+#include <boost/enums/pp/enum_declaration.hpp>
 
 
 #define CTOR
@@ -47,7 +48,7 @@
     Enum1,
     Enum2
   };
-};
+};
 typedef boost::enums::enum_type_cons<EnumClassNS, unsigned char> EnumClass;
 
 #endif

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-24 19:55:07 EDT (Thu, 24 Mar 2011)
@@ -17,7 +17,45 @@
 #include <boost/enums/scoped.hpp>
 #include <boost/enums/ordinal.hpp>
 #include <cstddef>
+#include <boost/enums/pp/enum_declaration.hpp>
 
+#if 1
+BOOST_ENUMS_ENUM_CLASS_DCL_CONS((EC3), int,
+ ( (Enum0) )
+ ( (Enum1) )
+ ( (Enum2) )
+ , linear_enum_traiter)
+
+
+//~ enum class EC3 : int { Enum0 , Enum1 , Enum2 } ;
+//~ inline bool operator ==(EC3 lhs, EC3 rhs) { return (int)(lhs) == (int)(rhs); }
+//~ inline bool operator !=(EC3 lhs, EC3 rhs) { return (int)(lhs) != (int)(rhs); }
+//~ inline bool operator <(EC3 lhs, EC3 rhs) { return (int)(lhs) < (int)(rhs); }
+//~ inline bool operator <=(EC3 lhs, EC3 rhs) { return (int)(lhs) <= (int)(rhs); }
+//~ inline bool operator >(EC3 lhs, EC3 rhs) { return (int)(lhs) > (int)(rhs); }
+//~ inline bool operator >=(EC3 lhs, EC3 rhs) { return (int)(lhs) >= (int)(rhs); }
+//~ namespace boost { namespace enums { namespace meta {
+ //~ template <> struct underlying_type<EC3> { typedef int type; };
+ //~ } } }
+ //~ inline EC3 convert_to(int v , boost::dummy::type_tag<EC3> const& ) { return EC3(v); }
+ //~ inline EC3 convert_to(boost::enums::native_type<EC3>::type v , boost::dummy::type_tag<EC3> const& ) { return v; }
+ //~ inline int convert_to(EC3 v , boost::dummy::type_tag<int> const& ) { return boost::enums::underlying_value(v); }
+ //~ namespace boost { namespace enums { namespace meta {
+ //~ template <> struct size< EC3> { static const std::size_t value=3; };
+ //~ template <> struct pos<EC3, EC3 :: Enum0> { static const std::size_t value = 0; };
+ //~ template <> struct val<EC3, 0> { static const boost::enums::native_type<EC3>::type value = EC3::Enum0; };
+ //~ template <> struct pos<EC3, EC3 :: Enum1> { static const std::size_t value = 1; };
+ //~ template <> struct val<EC3, 1> { static const boost::enums::native_type<EC3>::type value = EC3::Enum1; };
+ //~ template <> struct pos<EC3, EC3 :: Enum2> { static const std::size_t value = 2; };
+ //~ template <> struct val<EC3, 2> { static const boost::enums::native_type<EC3>::type value = EC3::Enum2; };
+ //~ template <> struct enum_traits< EC3> : linear_enum_traiter< EC3> {};
+ //~ } } }
+ //~ inline EC3 convert_to( const char* str, boost::dummy::type_tag<EC3> const& ) { if (strcmp( str, "Enum0" ) == 0) { return boost::convert_to<EC3>( EC3::Enum0 ); } if (strcmp( str, "Enum1" ) == 0) { return boost::convert_to<EC3>( EC3::Enum1 ); } if (strcmp( str, "Enum2" ) == 0) { return boost::convert_to<EC3>( EC3::Enum2 ); } throw "invalid string for " "EC3"; }
+ //~ inline EC3 convert_to( const std::string& str, boost::dummy::type_tag<EC3> const& ) { return boost::convert_to<EC3>( str.c_str() ); }
+ //~ inline const char* c_str(EC3 e) {
+ //~ switch (boost::enums::native_value(e)) { case EC3::Enum0 : return("Enum0"); case EC3::Enum1 : return("Enum1"); case EC3::Enum2 : return("Enum2"); default: throw "invalid value for " "EC3"; } }
+
+#else
 #if 0
   BOOST_ENUM_CLASS_START(EC3, int) {
     Enum0,
@@ -32,7 +70,7 @@
     Enum1,
     Enum2
   };
-};
+};
 typedef boost::enums::enum_class_cons<EC3NS, unsigned char> EC3;
 #endif
 BOOST_ENUMS_SPECIALIZATIONS(EC3, int)
@@ -89,3 +127,4 @@
 }
 
 #endif
+#endif

Modified: sandbox/enums/libs/enums/test/ExType.hpp
==============================================================================
--- sandbox/enums/libs/enums/test/ExType.hpp (original)
+++ sandbox/enums/libs/enums/test/ExType.hpp 2011-03-24 19:55:07 EDT (Thu, 24 Mar 2011)
@@ -18,7 +18,15 @@
 #include <boost/enums/scoped.hpp>
 #include <boost/enums/ordinal.hpp>
 #include <cstddef>
+#include <boost/enums/pp/enum_declaration.hpp>
 
+#if 1
+BOOST_ENUMS_ENUM_TYPE_DCL_CONS((EC3), int,
+ ( (Enum0) )
+ ( (Enum1) )
+ ( (Enum2) )
+ , linear_enum_traiter)
+#else
 #if 0
   BOOST_ENUM_TYPE_START(EC3, int) {
     Enum0,
@@ -33,7 +41,7 @@
     Enum1,
     Enum2
   };
-};
+};
 typedef boost::enums::enum_type_cons<EC3NS, unsigned char> EC3;
 #endif
 BOOST_ENUMS_SPECIALIZATIONS(EC3, int)
@@ -90,3 +98,4 @@
 }
 
 #endif
+#endif

Modified: sandbox/enums/libs/enums/test/enum_class/enum_inside_union_cons.pass.cpp
==============================================================================
--- sandbox/enums/libs/enums/test/enum_class/enum_inside_union_cons.pass.cpp (original)
+++ sandbox/enums/libs/enums/test/enum_class/enum_inside_union_cons.pass.cpp 2011-03-24 19:55:07 EDT (Thu, 24 Mar 2011)
@@ -30,35 +30,35 @@
   Default = 3,
   Enum1,
   Enum2
-};
+};
 
 struct UNS {
 enum type {
     Default = 3,
     Enum1,
     Enum2
-};
-};
-
+};
+};
+
 template <typename E>
-struct NS
+struct NS
 {
   typedef E type;
 };
-
+
 
 template <typename E>
-struct EC1 : NS<E>
+struct EC1 : NS<E>
 {
 };
 
 template <typename SE>
-struct EC2 : SE
+struct EC2 : SE
 {
 };
 
 typedef EC2<UNS> ScopedEnum2;
-static const ScopedEnum2::type e1 = ScopedEnum2::Enum1;
+static const ScopedEnum2::type e1 = ScopedEnum2::Enum1;
 typedef EC1<ExtrinsecEnum> ScopedEnum1;
 //static const ScopedEnum1::type e2 = ScopedEnum1::Enum1; //error: ‘Enum1’ is not a member of ‘ScopedEnum1’
 
@@ -79,35 +79,84 @@
 #define MyENUMS ( (E0)(3) ) ( (E1) ) ( (E2) )
 
 
-BOOST_ENUM_NS_CLASS_START(MyNS_EC, int)
-{
- BOOST_ENUMS_ENUMERATOR_LIST_GENERATE(MyENUMS)
-}
-BOOST_ENUM_NS_CLASS_CONS_END(MyNS_EC, int)
+BOOST_ENUM_NS_CLASS_START(MyNS_EC, int)
+{
+ BOOST_ENUMS_ENUMERATOR_LIST_GENERATE(MyENUMS)
+}
+BOOST_ENUM_NS_CLASS_CONS_END(MyNS_EC, int)
 BOOST_ENUMS_ENUM_DCL_SPE(MyNS_EC, MyENUMS, linear_enum_traiter)
-namespace boost {
- namespace enums {
- namespace meta {
- BOOST_ENUMS_ENUM_DCL_SIZE_SPE(MyNS_EC, MyENUMS)
- BOOST_PP_SEQ_FOR_EACH(
- BOOST_ENUMS_ENUM_DCL_POS_VAL_SPE,
- BOOST_ENUMS_NAMESPACES_CLASS_QNAME(MyNS_EC),
- MyENUMS
- )
- BOOST_ENUMS_ENUM_DCL_TRAITS_SPE(MyNS_EC, linear_enum_traiter)
- }
- }
+namespace boost {
+ namespace enums {
+ namespace meta {
+ BOOST_ENUMS_ENUM_DCL_SIZE_SPE(MyNS_EC, MyENUMS)
+ BOOST_PP_SEQ_FOR_EACH(
+ BOOST_ENUMS_ENUM_DCL_POS_VAL_SPE,
+ BOOST_ENUMS_NAMESPACES_CLASS_QNAME(MyNS_EC),
+ MyENUMS
+ )
+ BOOST_ENUMS_ENUM_DCL_TRAITS_SPE(MyNS_EC, linear_enum_traiter)
+ }
+ }
 }
 #else
 
 
-BOOST_ENUMS_ENUM_CLASS_DCL_CONS((Ex)(EC_Cons), int,
+BOOST_ENUMS_ENUM_CLASS_DCL_CONS((Ex)(EC_Cons), int,
                                 ( (E0)(3) )
                                 ( (E1) )
                                 ( (E2) )
                                 , linear_enum_traiter)
 
 
+//~ namespace Ex {
+ //~ enum class EC_Cons : int { E0 = 3 , E1 , E2 } ;
+ //~ inline bool operator ==(EC_Cons lhs, EC_Cons rhs) { return (int)(lhs) == (int)(rhs); }
+ //~ inline bool operator !=(EC_Cons lhs, EC_Cons rhs) { return (int)(lhs) != (int)(rhs); }
+ //~ inline bool operator <(EC_Cons lhs, EC_Cons rhs) { return (int)(lhs) < (int)(rhs); }
+ //~ inline bool operator <=(EC_Cons lhs, EC_Cons rhs) { return (int)(lhs) <= (int)(rhs); }
+ //~ inline bool operator >(EC_Cons lhs, EC_Cons rhs) { return (int)(lhs) > (int)(rhs); }
+ //~ inline bool operator >=(EC_Cons lhs, EC_Cons rhs) { return (int)(lhs) >= (int)(rhs);}
+//~ }
+ //~ namespace boost {
+ //~ namespace enums {
+ //~ namespace meta {
+ //~ template <> struct underlying_type<Ex::EC_Cons> { typedef int type; };
+ //~ }
+ //~ }
+ //~ }
+//~ namespace Ex {
+ //~ inline EC_Cons convert_to(int v , boost::dummy::type_tag<EC_Cons> const& ) { return EC_Cons(v); }
+ //~ inline EC_Cons convert_to(boost::enums::native_type<EC_Cons>::type v , boost::dummy::type_tag<EC_Cons> const& ) { return v; }
+ //~ inline int convert_to(EC_Cons v , boost::dummy::type_tag<int> const& ) { return boost::enums::underlying_value(v); }
+//~ }
+ //~ namespace boost {
+ //~ namespace enums {
+ //~ namespace meta {
+ //~ template <> struct size<Ex :: EC_Cons> { static const std::size_t value=3; };
+ //~ template <> struct pos<Ex :: EC_Cons, Ex :: EC_Cons :: E0> { static const std::size_t value = 0; };
+ //~ template <> struct val<Ex :: EC_Cons, 0> { static const boost::enums::native_type<Ex :: EC_Cons>::type value = Ex :: EC_Cons::E0; };
+ //~ template <> struct pos<Ex :: EC_Cons, Ex :: EC_Cons :: E1> { static const std::size_t value = 1; };
+ //~ template <> struct val<Ex :: EC_Cons, 1> { static const boost::enums::native_type<Ex :: EC_Cons>::type value = Ex :: EC_Cons::E1; };
+ //~ template <> struct pos<Ex :: EC_Cons, Ex :: EC_Cons :: E2> { static const std::size_t value = 2; };
+ //~ template <> struct val<Ex :: EC_Cons, 2> { static const boost::enums::native_type<Ex :: EC_Cons>::type value = Ex :: EC_Cons::E2; };
+ //~ template <> struct enum_traits<Ex :: EC_Cons> : linear_enum_traiter<Ex :: EC_Cons> {};
+ //~ }
+ //~ }
+ //~ }
+ //~ namespace Ex {
+ //~ inline EC_Cons convert_to( const char* str, boost::dummy::type_tag<EC_Cons> const& ) { if (strcmp( str, "E0" ) == 0) { return boost::convert_to<EC_Cons>( EC_Cons::E0 ); } if (strcmp( str, "E1" ) == 0) { return boost::convert_to<EC_Cons>( EC_Cons::E1 ); } if (strcmp( str, "E2" ) == 0) { return boost::convert_to<EC_Cons>( EC_Cons::E2 ); } throw "invalid string for " "EC_Cons"; }
+ //~ inline EC_Cons convert_to( const std::string& str, boost::dummy::type_tag<EC_Cons> const& ) { return boost::convert_to<EC_Cons>( str.c_str() ); }
+ //~ inline const char* c_str(EC_Cons e) {
+ //~ switch (boost::enums::native_value(e)) {
+ //~ case EC_Cons::E0 : return("E0");
+ //~ case EC_Cons::E1 : return("E1");
+ //~ case EC_Cons::E2 : return("E2");
+ //~ default: throw "invalid value for " "EC_Cons";
+ //~ }
+ //~ }
+ //~ }
+
+
 #endif
 #endif
 

Modified: sandbox/enums/libs/enums/test/enum_range/random_access_range_concept.pass.cpp
==============================================================================
--- sandbox/enums/libs/enums/test/enum_range/random_access_range_concept.pass.cpp (original)
+++ sandbox/enums/libs/enums/test/enum_range/random_access_range_concept.pass.cpp 2011-03-24 19:55:07 EDT (Thu, 24 Mar 2011)
@@ -24,7 +24,7 @@
 
   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 < iterator_range< range_detail::integer_iterator<int> > > ));
 
 
 // BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept < enum_range<EnumClass> > ));

Modified: sandbox/enums/libs/enums/test/f.hpp
==============================================================================
--- sandbox/enums/libs/enums/test/f.hpp (original)
+++ sandbox/enums/libs/enums/test/f.hpp 2011-03-24 19:55:07 EDT (Thu, 24 Mar 2011)
@@ -11,3 +11,4 @@
 //////////////////////////////////////////////////////////////////////////////
 
 void f(int i);
+


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