Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69499 - sandbox/enums/libs/enums/test
From: vicente.botet_at_[hidden]
Date: 2011-03-02 19:16:28


Author: viboes
Date: 2011-03-02 19:16:22 EST (Wed, 02 Mar 2011)
New Revision: 69499
URL: http://svn.boost.org/trac/boost/changeset/69499

Log:
Enums: Change int by std::size_t when a size is intendeed
Text files modified:
   sandbox/enums/libs/enums/test/EnumClass.hpp | 14 +++++++-------
   sandbox/enums/libs/enums/test/Ex.hpp | 12 ++++++------
   2 files changed, 13 insertions(+), 13 deletions(-)

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-02 19:16:22 EST (Wed, 02 Mar 2011)
@@ -213,22 +213,22 @@
     template <>
     struct size<EnumClass>
     {
- static const int value = 3;
+ static const std::size_t value = 3;
     };
     template <>
     struct pos<EnumClass, EnumClass::Default>
     {
- static const int value = 0;
+ static const std::size_t value = 0;
     };
     template <>
     struct pos<EnumClass, EnumClass::Enum1>
     {
- static const int value = 1;
+ static const std::size_t value = 1;
     };
     template <>
     struct pos<EnumClass, EnumClass::Enum2>
     {
- static const int value = 2;
+ static const std::size_t value = 2;
     };
 
     template <>
@@ -250,17 +250,17 @@
     template <>
     struct enum_traits<EnumClass> : enum_traiter<EnumClass>
     {
- static int pos(EnumClass e)
+ 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: return -1;
+ default: throw "bad_parameterparameter";
         }
       }
- static EnumClass val(int p)
+ static EnumClass val(std::size_t p)
       {
         switch (p)
         {

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-02 19:16:22 EST (Wed, 02 Mar 2011)
@@ -39,17 +39,17 @@
     template <>
     struct pos<EC3, EC3::Enum0>
     {
- static const int value = 0;
+ static const std::size_t value = 0;
     };
     template <>
     struct pos<EC3, EC3::Enum1>
     {
- static const int value = 1;
+ static const std::size_t value = 1;
     };
     template <>
     struct pos<EC3, EC3::Enum2>
     {
- static const int value = 2;
+ static const std::size_t value = 2;
     };
 
     template <>
@@ -71,17 +71,17 @@
     template <>
     struct enum_traits<EC3> : enum_traiter<EC3>
     {
- static int pos(EC3 e)
+ 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: return -1;
+ default: throw "bad_parameter";
         }
       }
- static EC3 val(int p)
+ static EC3 val(std::size_t p)
       {
         switch (p)
         {


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