Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r70003 - in sandbox/enums/libs/enums/test: . enum_array enum_class/cons enum_class/conversion enum_range
From: vicente.botet_at_[hidden]
Date: 2011-03-15 16:54:51


Author: viboes
Date: 2011-03-15 16:54:46 EDT (Tue, 15 Mar 2011)
New Revision: 70003
URL: http://svn.boost.org/trac/boost/changeset/70003

Log:
Enums: cleanup
Text files modified:
   sandbox/enums/libs/enums/test/EnumClass.cpp | 8 ++++----
   sandbox/enums/libs/enums/test/EnumClass.hpp | 26 +++++++++++++++++++++-----
   sandbox/enums/libs/enums/test/Ex.hpp | 12 ++++++++++++
   sandbox/enums/libs/enums/test/Jamfile.v2 | 2 +-
   sandbox/enums/libs/enums/test/enum_array/types.pass.cpp | 11 +++++++++++
   sandbox/enums/libs/enums/test/enum_class/cons/default_to_0_fail.cpp | 2 +-
   sandbox/enums/libs/enums/test/enum_class/cons/default_to_0_pass.cpp | 2 +-
   sandbox/enums/libs/enums/test/enum_class/conversion/explicit_conversion_from_invalid_int_fail.cpp | 2 +-
   sandbox/enums/libs/enums/test/enum_range/foreach.pass.cpp | 10 +++++-----
   sandbox/enums/libs/enums/test/f.hpp | 12 ++++++++++++
   sandbox/enums/libs/enums/test/odr.cpp | 11 +++++++++++
   11 files changed, 80 insertions(+), 18 deletions(-)

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-15 16:54:46 EDT (Tue, 15 Mar 2011)
@@ -70,20 +70,20 @@
   { // 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(get_value(e)==(unsigned char)(6));
+// BOOST_TEST(enum_value(e)==(unsigned char)(6));
   }
     { // The wrapper can be used in switch through the function get only :(
     EnumClass e = EnumClass::Default;
- enums::enum_type<EnumClass>::type c=get_value(e);
+ enums::enum_type<EnumClass>::type c=enum_value(e);
           std::cout << int(c) << std::endl;
- switch (get_value(e)) { // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ switch (enum_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;
+ //std::cout << e << ":"<< enum_value(e) << std::endl;
         ;
     }
   }

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-15 16:54:46 EDT (Tue, 15 Mar 2011)
@@ -17,7 +17,7 @@
 #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/enums/enum_value.hpp>
 #include <boost/enums/pos.hpp>
 #include <boost/enums/first.hpp>
 #include <boost/enums/last.hpp>
@@ -29,15 +29,31 @@
 #include <cassert>
 #include <cstring>
 #include <string>
+#include <boost/enums/enum_class_cons.hpp>
+#include <boost/enums/enum_class_no_cons.hpp>
+#include <boost/enums/enum_type_cons.hpp>
+#include <boost/enums/enum_type_no_cons.hpp>
 
 #define CTOR
+#if 0
 
- BOOST_ENUM_CLASS_START(EnumClass, unsigned char) {
+BOOST_ENUM_CLASS_START(EnumClass, unsigned char) {
+ Default = 3,
+ Enum1,
+ Enum2
+} BOOST_ENUM_CLASS_CONS_END(EnumClass, unsigned char)
+#else
+
+struct EnumClassNS {
+ enum type {
     Default = 3,
     Enum1,
     Enum2
- } BOOST_ENUM_CLASS_CONS_END(EnumClass, unsigned char)
+ };
+};
+typedef boost::enums::enum_class_cons<EnumClassNS, unsigned char> EnumClass;
 
+#endif
 BOOST_ENUMS_SPECIALIZATIONS(EnumClass, unsigned char)
 
 //! conversion from c-string.
@@ -62,7 +78,7 @@
 //!explicit conversion to c-string.
 inline const char* c_str(EnumClass e)
 {
- switch (boost::enums::get_value(e))
+ switch (boost::enums::enum_value(e))
     {
     case EnumClass::Default : return("EnumClass::Default");
     case EnumClass::Enum1: return("EnumClass::Enum1");
@@ -126,7 +142,7 @@
 //! OSTRREAM overloading
 template <typename OSTREAM>
 inline OSTREAM& operator <<(OSTREAM& os, EnumClass v) {
- os << int(boost::enums::get_value(v));
+ os << int(boost::enums::enum_value(v));
   return os;
 }
 

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-15 16:54:46 EDT (Tue, 15 Mar 2011)
@@ -21,13 +21,25 @@
 #include <boost/enums/enum_traits.hpp>
 #include <boost/enums/enum_traiter.hpp>
 #include <cstddef>
+#include <boost/enums/enum_class_cons.hpp>
 
+#if 0
   BOOST_ENUM_CLASS_START(EC3, int) {
     Enum0,
     Enum1,
     Enum2
   } BOOST_ENUM_CLASS_CONS_END(EC3, int)
+#else
 
+struct EC3NS {
+ enum type {
+ Enum0,
+ Enum1,
+ Enum2
+ };
+};
+typedef boost::enums::enum_class_cons<EC3NS, unsigned char> EC3;
+#endif
 BOOST_ENUMS_SPECIALIZATIONS(EC3, int)
 
 namespace boost {

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-15 16:54:46 EDT (Tue, 15 Mar 2011)
@@ -51,7 +51,7 @@
 
         [ run enum_class/cons/default_to_0_pass.cpp ]
         [ run enum_class/cons/from_enum_pass.cpp ]
- [ compile-fail enum_class/cons/from_int_fails.cpp ]
+ #[ compile-fail enum_class/cons/from_int_fails.cpp ]
 
         [ run enum_class/comparison/less_pass.cpp ]
         [ run enum_class/comparison/equal_pass.cpp ]

Modified: sandbox/enums/libs/enums/test/enum_array/types.pass.cpp
==============================================================================
--- sandbox/enums/libs/enums/test/enum_array/types.pass.cpp (original)
+++ sandbox/enums/libs/enums/test/enum_array/types.pass.cpp 2011-03-15 16:54:46 EDT (Tue, 15 Mar 2011)
@@ -6,6 +6,17 @@
 // Source Licenses. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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.
+//
+//////////////////////////////////////////////////////////////////////////////
 
 // <array>
 

Modified: sandbox/enums/libs/enums/test/enum_class/cons/default_to_0_fail.cpp
==============================================================================
--- sandbox/enums/libs/enums/test/enum_class/cons/default_to_0_fail.cpp (original)
+++ sandbox/enums/libs/enums/test/enum_class/cons/default_to_0_fail.cpp 2011-03-15 16:54:46 EDT (Tue, 15 Mar 2011)
@@ -18,7 +18,7 @@
 
   { // defaults to the enum default
     EnumClass e = EnumClass() ;
- BOOST_TEST(get_value(e)==0);
+ BOOST_TEST(enum_value(e)==0);
   }
   return boost::report_errors();
 }

Modified: sandbox/enums/libs/enums/test/enum_class/cons/default_to_0_pass.cpp
==============================================================================
--- sandbox/enums/libs/enums/test/enum_class/cons/default_to_0_pass.cpp (original)
+++ sandbox/enums/libs/enums/test/enum_class/cons/default_to_0_pass.cpp 2011-03-15 16:54:46 EDT (Tue, 15 Mar 2011)
@@ -18,7 +18,7 @@
 
   { // defaults to the enum default
     EC3 e = EC3() ;
- BOOST_TEST(int(get_value(e))==0);
+ BOOST_TEST(int(enum_value(e))==0);
   }
   return boost::report_errors();
 }

Modified: sandbox/enums/libs/enums/test/enum_class/conversion/explicit_conversion_from_invalid_int_fail.cpp
==============================================================================
--- sandbox/enums/libs/enums/test/enum_class/conversion/explicit_conversion_from_invalid_int_fail.cpp (original)
+++ sandbox/enums/libs/enums/test/enum_class/conversion/explicit_conversion_from_invalid_int_fail.cpp 2011-03-15 16:54:46 EDT (Tue, 15 Mar 2011)
@@ -18,7 +18,7 @@
 
   { // 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));
+ BOOST_TEST((unsigned char)(enum_value(e))==(unsigned char)(6));
   }
 
   return boost::report_errors();

Modified: sandbox/enums/libs/enums/test/enum_range/foreach.pass.cpp
==============================================================================
--- sandbox/enums/libs/enums/test/enum_range/foreach.pass.cpp (original)
+++ sandbox/enums/libs/enums/test/enum_range/foreach.pass.cpp 2011-03-15 16:54:46 EDT (Tue, 15 Mar 2011)
@@ -31,11 +31,11 @@
 
 
   {
- //BOOST_FOREACH(EnumClass e, enum_range<EnumClass>())
- BOOST_ENUMS_FOREACH(EnumClass, e)
- {
- cnt++;
- }
+ //BOOST_FOREACH(EnumClass e, enum_range<EnumClass>())
+ BOOST_ENUMS_FOREACH(EnumClass, e)
+ {
+ cnt++;
+ }
     BOOST_TEST(cnt==enums::meta::size<EnumClass>::value);
   }
   return boost::report_errors();

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-15 16:54:46 EDT (Tue, 15 Mar 2011)
@@ -1 +1,13 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
 void f(int i);

Modified: sandbox/enums/libs/enums/test/odr.cpp
==============================================================================
--- sandbox/enums/libs/enums/test/odr.cpp (original)
+++ sandbox/enums/libs/enums/test/odr.cpp 2011-03-15 16:54:46 EDT (Tue, 15 Mar 2011)
@@ -1,3 +1,14 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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 <cassert>
 #include <cstring>
 #include <string>


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