Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69573 - in sandbox/enums/libs/enums/test: . enum_class enum_class/comparison enum_class/cons enum_class/conversion enum_class/meta
From: vicente.botet_at_[hidden]
Date: 2011-03-04 19:32:15


Author: viboes
Date: 2011-03-04 19:32:10 EST (Fri, 04 Mar 2011)
New Revision: 69573
URL: http://svn.boost.org/trac/boost/changeset/69573

Log:
Enums: Added tests for enum class and meta functions
Added:
   sandbox/enums/libs/enums/test/enum_class/
   sandbox/enums/libs/enums/test/enum_class/comparison/
   sandbox/enums/libs/enums/test/enum_class/comparison/equal_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/comparison/less_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/comparison/not_equal_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/cons/
   sandbox/enums/libs/enums/test/enum_class/cons/default_to_0_fail.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/cons/default_to_0_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/cons/from_enum_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/cons/from_int_fails.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/conversion/
   sandbox/enums/libs/enums/test/enum_class/conversion/implicit_conversion_to_bool_fails.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/conversion/implicit_conversion_to_ut_fails.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/has_same_size_as_ut_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/meta/
   sandbox/enums/libs/enums/test/enum_class/meta/first_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/meta/last_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/meta/pos_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/meta/pred_of_first_fail.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/meta/pred_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/meta/size_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/meta/succ_of_last_fail.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/meta/succ_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/meta/val_of_invalid_fail.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/meta/val_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_class/underlying_type_pass.cpp (contents, props changed)
Text files modified:
   sandbox/enums/libs/enums/test/EnumClass.hpp | 14 ++++++------
   sandbox/enums/libs/enums/test/Ex.hpp | 40 ++++++++++++++++++++------------------
   sandbox/enums/libs/enums/test/Jamfile.v2 | 42 +++++++++++++++++++++++++--------------
   3 files changed, 55 insertions(+), 41 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-04 19:32:10 EST (Fri, 04 Mar 2011)
@@ -213,38 +213,38 @@
     template <>
     struct size<EnumClass>
     {
- static const std::size_t value = 3;
+ BOOST_STATIC_CONSTEXPR std::size_t value = 3;
     };
     template <>
     struct pos<EnumClass, EnumClass::Default>
     {
- static const std::size_t value = 0;
+ BOOST_STATIC_CONSTEXPR std::size_t value = 0;
     };
     template <>
     struct pos<EnumClass, EnumClass::Enum1>
     {
- static const std::size_t value = 1;
+ BOOST_STATIC_CONSTEXPR std::size_t value = 1;
     };
     template <>
     struct pos<EnumClass, EnumClass::Enum2>
     {
- static const std::size_t value = 2;
+ BOOST_STATIC_CONSTEXPR std::size_t value = 2;
     };
 
     template <>
     struct val<EnumClass, 0>
     {
- static const boost::enums::enum_type<EnumClass>::type value = EnumClass::Default;
+ BOOST_STATIC_CONSTEXPR boost::enums::enum_type<EnumClass>::type value = EnumClass::Default;
     };
     template <>
     struct val<EnumClass, 1>
     {
- static const boost::enums::enum_type<EnumClass>::type value = EnumClass::Enum1;
+ BOOST_STATIC_CONSTEXPR boost::enums::enum_type<EnumClass>::type value = EnumClass::Enum1;
     };
     template <>
     struct val<EnumClass, 2>
     {
- static const boost::enums::enum_type<EnumClass>::type value = EnumClass::Enum2;
+ BOOST_STATIC_CONSTEXPR boost::enums::enum_type<EnumClass>::type value = EnumClass::Enum2;
     };
     } // namespace meta
     template <>

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-04 19:32:10 EST (Fri, 04 Mar 2011)
@@ -35,47 +35,49 @@
     template <>
     struct size<EC3>
     {
+ //~ BOOST_STATIC_CONSTEXPR
       static const std::size_t value;
- };
+ };
+ //~ BOOST_CONSTEXPR
     const std::size_t size<EC3>::value = 3;
     template <>
     struct pos<EC3, EC3::Enum0>
     {
- static const std::size_t value = 0;
- };
+ BOOST_STATIC_CONSTEXPR std::size_t value = 0;
+ };
     template <>
     struct pos<EC3, EC3::Enum1>
     {
- static const std::size_t value = 1;
- };
+ BOOST_STATIC_CONSTEXPR std::size_t value = 1;
+ };
     template <>
     struct pos<EC3, EC3::Enum2>
     {
- static const std::size_t value = 2;
- };
+ BOOST_STATIC_CONSTEXPR std::size_t value = 2;
+ };
 
     template <>
     struct val<EC3, 0>
     {
- static const boost::enums::enum_type<EC3>::type value = EC3::Enum0;
- };
+ BOOST_STATIC_CONSTEXPR boost::enums::enum_type<EC3>::type value = EC3::Enum0;
+ };
     template <>
     struct val<EC3, 1>
     {
- static const boost::enums::enum_type<EC3>::type value = EC3::Enum1;
- };
+ BOOST_STATIC_CONSTEXPR boost::enums::enum_type<EC3>::type value = EC3::Enum1;
+ };
     template <>
     struct val<EC3, 2>
     {
- static const boost::enums::enum_type<EC3>::type value = EC3::Enum2;
- };
+ 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> : enum_traiter<EC3>
     {
- static std::size_t pos(EC3 e)
+ static std::size_t pos(EC3 e)
       {
- switch (boost::enums::get_value(e))
+ switch (boost::enums::get_value(e))
         {
           case EC3::Enum0: return 0;
           case EC3::Enum1: return 1;
@@ -83,9 +85,9 @@
           default: throw "bad_parameter";
         }
       }
- static EC3 val(std::size_t p)
+ static EC3 val(std::size_t p)
       {
- switch (p)
+ switch (p)
         {
           case 0: return boost::convert_to<EC3>(EC3::Enum0);
           case 1: return boost::convert_to<EC3>(EC3::Enum1);
@@ -93,7 +95,7 @@
           default: throw "bad_parameter";
         }
       }
- };
+ };
   }
 }
 

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-04 19:32:10 EST (Fri, 04 Mar 2011)
@@ -39,20 +39,33 @@
         <toolset>msvc:<cxxflags>/wd4127
     ;
 
- test-suite "examples"
+ test-suite "enum_class"
         :
- [ compile-fail construction_from_int_fails.cpp ]
- [ run comparaision.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 ]
+ [ compile enum_class/has_same_size_as_ut_pass.cpp ]
+ [ compile enum_class/underlying_type_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 ]
+
+ [ run enum_class/comparison/less_pass.cpp ]
+ [ run enum_class/comparison/equal_pass.cpp ]
+ [ run enum_class/comparison/not_equal_pass.cpp ]
+
+ [ compile-fail enum_class/conversion/implicit_conversion_to_ut_fails.cpp ]
+ [ compile-fail enum_class/conversion/implicit_conversion_to_bool_fails.cpp ]
+
+ [ compile enum_class/meta/first_pass.cpp ]
+ [ compile enum_class/meta/last_pass.cpp ]
+ [ compile enum_class/meta/pos_pass.cpp ]
+ [ compile enum_class/meta/val_pass.cpp ]
+ [ compile enum_class/meta/pred_pass.cpp ]
+ [ compile enum_class/meta/succ_pass.cpp ]
+ [ compile-fail enum_class/meta/succ_of_last_fail.cpp ]
+ [ compile-fail enum_class/meta/pred_of_first_fail.cpp ]
+ [ compile-fail enum_class/meta/val_of_invalid_fail.cpp ]
+
         [ run EnumClass.cpp odr.cpp ]
         ;
 
@@ -68,7 +81,7 @@
         [ run enum_array/special/swap.pass.cpp : : : : enum_array__special__swap__pass ]
         [ run enum_array/fill/fill.pass.cpp : : : : enum_array__fill__fill__pass ]
         ;
-
+
   test-suite "enum_set"
         :
         [ run enum_set/version.pass.cpp : : : : enum_set__version__pass ]
@@ -78,4 +91,3 @@
         #[ 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 ]
   ;
-
\ No newline at end of file

Added: sandbox/enums/libs/enums/test/enum_class/comparison/equal_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/comparison/equal_pass.cpp 2011-03-04 19:32:10 EST (Fri, 04 Mar 2011)
@@ -0,0 +1,38 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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);
+ }
+ {
+ EnumClass e;
+ e = EnumClass::Enum2;
+ BOOST_TEST(EnumClass::Enum2==e);
+ }
+ {
+ EnumClass e1, e2;
+ e1 = EnumClass::Enum2;
+ e2 = EnumClass::Enum2;
+ BOOST_TEST(e1==e2);
+ }
+
+ return boost::report_errors();
+}

Added: sandbox/enums/libs/enums/test/enum_class/comparison/less_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/comparison/less_pass.cpp 2011-03-04 19:32:10 EST (Fri, 04 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>
+
+int main() {
+ // is less than comparable
+ {
+ EnumClass e;
+ e= EnumClass::Default;
+ BOOST_TEST(e < EnumClass::Enum2);
+ }
+ {
+ EnumClass e;
+ e= EnumClass::Enum2;
+ BOOST_TEST(EnumClass::Enum1<e);
+ }
+ {
+ EnumClass e0;
+ e0= EnumClass::Default;
+ EnumClass e1;
+ e1= EnumClass::Enum2;
+ BOOST_TEST(e0 < e1);
+ }
+ return boost::report_errors();
+}

Added: sandbox/enums/libs/enums/test/enum_class/comparison/not_equal_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/comparison/not_equal_pass.cpp 2011-03-04 19:32:10 EST (Fri, 04 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>
+
+int main() {
+ using namespace boost::enums;
+
+ // not equal comparable
+ {
+ EnumClass e;
+ e = EnumClass::Enum2;
+ BOOST_TEST(e!=EnumClass::Default);
+ }
+ {
+ EnumClass e;
+ e = EnumClass::Enum2;
+ BOOST_TEST(EnumClass::Default!=e);
+ }
+ {
+ EnumClass e1;
+ e1 = EnumClass::Enum1;
+ EnumClass e2;
+ e2 = EnumClass::Enum2;
+ BOOST_TEST(e1!=e2);
+ }
+
+ return boost::report_errors();
+}

Added: sandbox/enums/libs/enums/test/enum_class/cons/default_to_0_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/cons/default_to_0_fail.cpp 2011-03-04 19:32:10 EST (Fri, 04 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;
+
+ { // defaults to the enum default
+ EnumClass e = EnumClass() ;
+ BOOST_TEST(get_value(e)==0);
+ }
+ return boost::report_errors();
+}
+

Added: sandbox/enums/libs/enums/test/enum_class/cons/default_to_0_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/cons/default_to_0_pass.cpp 2011-03-04 19:32:10 EST (Fri, 04 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 "./Ex.hpp"
+#include <boost/detail/lightweight_test.hpp>
+
+int main() {
+ using namespace boost::enums;
+
+ { // defaults to the enum default
+ EC3 e = EC3() ;
+ BOOST_TEST(int(get_value(e))==0);
+ }
+ return boost::report_errors();
+}
+

Added: sandbox/enums/libs/enums/test/enum_class/cons/from_enum_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/cons/from_enum_pass.cpp 2011-03-04 19:32:10 EST (Fri, 04 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();
+}

Added: sandbox/enums/libs/enums/test/enum_class/cons/from_int_fails.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/cons/from_int_fails.cpp 2011-03-04 19:32:10 EST (Fri, 04 Mar 2011)
@@ -0,0 +1,21 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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);
+ (void)e;
+
+}

Added: sandbox/enums/libs/enums/test/enum_class/conversion/implicit_conversion_to_bool_fails.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/conversion/implicit_conversion_to_bool_fails.cpp 2011-03-04 19:32:10 EST (Fri, 04 Mar 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/enum_class/conversion/implicit_conversion_to_ut_fails.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/conversion/implicit_conversion_to_ut_fails.cpp 2011-03-04 19:32:10 EST (Fri, 04 Mar 2011)
@@ -0,0 +1,27 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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
+ (void)i;
+ }
+
+}

Added: sandbox/enums/libs/enums/test/enum_class/has_same_size_as_ut_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/has_same_size_as_ut_pass.cpp 2011-03-04 19:32:10 EST (Fri, 04 Mar 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/enum_class/meta/first_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/meta/first_pass.cpp 2011-03-04 19:32:10 EST (Fri, 04 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/static_assert.hpp>
+#include <boost/enums/mpl/enum_c.hpp>
+#include <boost/enums/mpl/equal_to.hpp>
+
+void pass() {
+ using namespace boost;
+ using namespace boost::enums;
+
+ { // has the same size as the underlying type
+ BOOST_STATIC_ASSERT((mpl::equal_to<
+ mpl::enum_c<EnumClass, meta::first<EnumClass>::value>,
+ mpl::enum_c<EnumClass, EnumClass::Default>
+ >::value));
+ }
+
+}

Added: sandbox/enums/libs/enums/test/enum_class/meta/last_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/meta/last_pass.cpp 2011-03-04 19:32:10 EST (Fri, 04 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/static_assert.hpp>
+#include <boost/enums/mpl/enum_c.hpp>
+#include <boost/enums/mpl/equal_to.hpp>
+
+void pass() {
+ using namespace boost;
+ using namespace boost::enums;
+
+ { // has the same size as the underlying type
+ BOOST_STATIC_ASSERT((mpl::equal_to<
+ mpl::enum_c<EnumClass, meta::last<EnumClass>::value>,
+ mpl::enum_c<EnumClass, EnumClass::Enum2>
+ >::value));
+ }
+
+}

Added: sandbox/enums/libs/enums/test/enum_class/meta/pos_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/meta/pos_pass.cpp 2011-03-04 19:32:10 EST (Fri, 04 Mar 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/static_assert.hpp>
+//~ #include <boost/enums/mpl/enum_c.hpp>
+//~ #include <boost/mpl/equal_to.hpp>
+
+void pass() {
+ //~ using namespace boost;
+ using namespace boost::enums;
+
+ { // has the same size as the underlying type
+ BOOST_STATIC_ASSERT((meta::pos<EnumClass, EnumClass::Enum1>::value == 1));
+ }
+
+}

Added: sandbox/enums/libs/enums/test/enum_class/meta/pred_of_first_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/meta/pred_of_first_fail.cpp 2011-03-04 19:32:10 EST (Fri, 04 Mar 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/enums/pred.hpp>
+#include <boost/enums/enum_type.hpp>
+
+void fail() {
+ using namespace boost::enums;
+
+ {
+ enum_type<EnumClass>::type e = meta::pred<EnumClass, EnumClass::Default>;
+ }
+
+}

Added: sandbox/enums/libs/enums/test/enum_class/meta/pred_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/meta/pred_pass.cpp 2011-03-04 19:32:10 EST (Fri, 04 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include "./EnumClass.hpp"
+#include <boost/static_assert.hpp>
+#include <boost/enums/pred.hpp>
+#include <boost/enums/mpl/enum_c.hpp>
+#include <boost/enums/mpl/equal_to.hpp>
+
+void pass() {
+ using namespace boost;
+ using namespace boost::enums;
+
+ {
+ BOOST_STATIC_ASSERT((mpl::equal_to<
+ mpl::enum_c<EnumClass, meta::pred<EnumClass,EnumClass::Enum1>::value>,
+ mpl::enum_c<EnumClass, EnumClass::Default>
+ >::value));
+
+ BOOST_STATIC_ASSERT((mpl::equal_to<
+ mpl::enum_c<EnumClass, meta::pred<EnumClass,EnumClass::Enum2>::value>,
+ mpl::enum_c<EnumClass, EnumClass::Enum1>
+ >::value));
+ }
+
+}

Added: sandbox/enums/libs/enums/test/enum_class/meta/size_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/meta/size_pass.cpp 2011-03-04 19:32:10 EST (Fri, 04 Mar 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(meta::size<EnumClass>::value == 3);
+ }
+
+}

Added: sandbox/enums/libs/enums/test/enum_class/meta/succ_of_last_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/meta/succ_of_last_fail.cpp 2011-03-04 19:32:10 EST (Fri, 04 Mar 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/enums/succ.hpp>
+#include <boost/enums/enum_type.hpp>
+
+void fail() {
+ using namespace boost::enums;
+
+ {
+ enum_type<EnumClass>::type e = meta::succ<EnumClass, EnumClass::Enum2>::value ;
+ }
+
+}

Added: sandbox/enums/libs/enums/test/enum_class/meta/succ_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/meta/succ_pass.cpp 2011-03-04 19:32:10 EST (Fri, 04 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include "./EnumClass.hpp"
+#include <boost/static_assert.hpp>
+#include <boost/enums/succ.hpp>
+#include <boost/enums/mpl/enum_c.hpp>
+#include <boost/enums/mpl/equal_to.hpp>
+
+void pass() {
+ using namespace boost;
+ using namespace boost::enums;
+
+ {
+ BOOST_STATIC_ASSERT((mpl::equal_to<
+ mpl::enum_c<EnumClass, meta::succ<EnumClass,EnumClass::Default>::value>,
+ mpl::enum_c<EnumClass, EnumClass::Enum1>
+ >::value));
+
+ BOOST_STATIC_ASSERT((mpl::equal_to<
+ mpl::enum_c<EnumClass, meta::succ<EnumClass,EnumClass::Enum1>::value>,
+ mpl::enum_c<EnumClass, EnumClass::Enum2>
+ >::value));
+ }
+
+}

Added: sandbox/enums/libs/enums/test/enum_class/meta/val_of_invalid_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/meta/val_of_invalid_fail.cpp 2011-03-04 19:32:10 EST (Fri, 04 Mar 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/static_assert.hpp>
+
+void fail() {
+ using namespace boost::enums;
+
+ { // has the same size as the underlying type
+ enum_type<EnumClass>::type e= meta::val<EnumClass,3>::value;
+ (void)(e);
+ }
+
+}

Added: sandbox/enums/libs/enums/test/enum_class/meta/val_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/meta/val_pass.cpp 2011-03-04 19:32:10 EST (Fri, 04 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/static_assert.hpp>
+#include <boost/enums/mpl/enum_c.hpp>
+#include <boost/enums/mpl/equal_to.hpp>
+
+void pass() {
+ using namespace boost;
+ using namespace boost::enums;
+
+ { // has the same size as the underlying type
+ BOOST_STATIC_ASSERT((mpl::equal_to<
+ mpl::enum_c<EnumClass, meta::val<EnumClass,1>::value>,
+ mpl::enum_c<EnumClass, EnumClass::Enum1>
+ >::value));
+ }
+
+}

Added: sandbox/enums/libs/enums/test/enum_class/underlying_type_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_class/underlying_type_pass.cpp 2011-03-04 19:32:10 EST (Fri, 04 Mar 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/static_assert.hpp>
+#include <boost/type_traits/is_same.hpp>
+
+void pass() {
+ using namespace boost::enums;
+
+ { // has the same size as the underlying type
+ BOOST_STATIC_ASSERT((boost::is_same<unsigned char,underlying_type<EnumClass>::type>::value));
+ }
+
+}


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