Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r70158 - in sandbox/enums/libs/enums/test: . enum_type enum_type/comparison enum_type/cons enum_type/conversion enum_type/meta
From: vicente.botet_at_[hidden]
Date: 2011-03-18 19:11:01


Author: viboes
Date: 2011-03-18 19:10:57 EDT (Fri, 18 Mar 2011)
New Revision: 70158
URL: http://svn.boost.org/trac/boost/changeset/70158

Log:
Enums: Added enum_type tests
Added:
   sandbox/enums/libs/enums/test/EnumType.hpp (contents, props changed)
   sandbox/enums/libs/enums/test/ExType.hpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/
   sandbox/enums/libs/enums/test/enum_type/comparison/
   sandbox/enums/libs/enums/test/enum_type/comparison/equal_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/comparison/less_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/comparison/not_equal_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/cons/
   sandbox/enums/libs/enums/test/enum_type/cons/default_to_0_fail.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/cons/default_to_0_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/cons/from_enum_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/cons/from_int_fails.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/conversion/
   sandbox/enums/libs/enums/test/enum_type/conversion/explicit_conversion_from_invalid_int_fail.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/conversion/explicit_conversion_from_valid_int_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/conversion/implicit_conversion_to_bool_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/conversion/implicit_conversion_to_ut_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/enum_inside_union_cons.fail.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/enum_inside_union_cons.pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/has_same_size_as_ut_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/inside_union_cons.fail.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/inside_union_cons.pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/inside_union_no_cons_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/meta/
   sandbox/enums/libs/enums/test/enum_type/meta/first_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/meta/last_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/meta/pos_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/meta/pred_of_first_fail.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/meta/pred_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/meta/size_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/meta/succ_of_last_fail.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/meta/succ_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/meta/val_of_invalid_fail.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/meta/val_pass.cpp (contents, props changed)
   sandbox/enums/libs/enums/test/enum_type/underlying_type_pass.cpp (contents, props changed)
Text files modified:
   sandbox/enums/libs/enums/test/Jamfile.v2 | 37 ++++++++++++++++++++++++++++++++++++-
   1 files changed, 36 insertions(+), 1 deletions(-)

Added: sandbox/enums/libs/enums/test/EnumType.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/EnumType.hpp 2011-03-18 19:10:57 EDT (Fri, 18 Mar 2011)
@@ -0,0 +1,146 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef ENUMTYPE_HPP
+#define ENUMTYPE_HPP
+
+
+#include <boost/enums/scoped/underlying_type.hpp>
+#include <boost/enums/scoped/native_type.hpp>
+#include <boost/enums/scoped/default_value.hpp>
+#include <boost/enums/scoped/native_value.hpp>
+#include <boost/enums/ordinal/pos.hpp>
+#include <boost/enums/ordinal/first.hpp>
+#include <boost/enums/ordinal/last.hpp>
+#include <boost/enums/ordinal/size.hpp>
+#include <boost/enums/ordinal/traits.hpp>
+#include <boost/conversion/convert_to.hpp>
+#include <boost/enums/ordinal/linear_traiter.hpp>
+#include <boost/enums/scoped/emulation.hpp>
+#include <cassert>
+#include <cstring>
+#include <string>
+
+
+#define CTOR
+#if 1
+
+BOOST_ENUM_TYPE_START(EnumClass, unsigned char) {
+ Default = 3,
+ Enum1,
+ Enum2
+} BOOST_ENUM_TYPE_CONS_END(EnumClass, unsigned char)
+#else
+
+struct EnumClassNS {
+ enum type {
+ Default = 3,
+ Enum1,
+ Enum2
+ };
+};
+typedef boost::enums::enum_type_cons<EnumClassNS, unsigned char> EnumClass;
+
+#endif
+BOOST_ENUMS_SPECIALIZATIONS(EnumClass, unsigned char)
+
+//! conversion from c-string.
+inline EnumClass convert_to(const char* str
+ , boost::dummy::type_tag<EnumClass> const&
+)
+{
+ if (strcmp(str, "Default") ==0) { return boost::convert_to<EnumClass>(EnumClass::Default); }
+ if (strcmp(str, "Enum1") ==0) { return boost::convert_to<EnumClass>(EnumClass::Enum1); }
+ if (strcmp(str, "Enum2") ==0) { return boost::convert_to<EnumClass>(EnumClass::Enum2); }
+ throw "invalid string for EnumClass";
+}
+
+//! conversion from std::string.
+inline EnumClass convert_to(const std::string& str
+ , boost::dummy::type_tag<EnumClass> const&
+)
+{
+ return boost::convert_to<EnumClass>(str.c_str());
+}
+
+//!explicit conversion to c-string.
+inline const char* c_str(EnumClass e)
+{
+ switch (boost::enums::native_value(e))
+ {
+ case EnumClass::Default : return("EnumClass::Default");
+ case EnumClass::Enum1: return("EnumClass::Enum1");
+ case EnumClass::Enum2 : return("EnumClass::Enum2");
+ default:
+ return("EnumClass::???");
+ }
+}
+
+namespace boost {
+ namespace enums {
+ namespace meta {
+
+ template <>
+ struct size<EnumClass>
+ {
+ BOOST_STATIC_CONSTEXPR std::size_t value = 3;
+ };
+ template <>
+ struct pos<EnumClass, EnumClass::Default>
+ {
+ BOOST_STATIC_CONSTEXPR std::size_t value = 0;
+ };
+ template <>
+ struct pos<EnumClass, EnumClass::Enum1>
+ {
+ BOOST_STATIC_CONSTEXPR std::size_t value = 1;
+ };
+ template <>
+ struct pos<EnumClass, EnumClass::Enum2>
+ {
+ BOOST_STATIC_CONSTEXPR std::size_t value = 2;
+ };
+
+ template <>
+ struct val<EnumClass, 0>
+ {
+ BOOST_STATIC_CONSTEXPR boost::enums::native_type<EnumClass>::type value = EnumClass::Default;
+ };
+ template <>
+ struct val<EnumClass, 1>
+ {
+ BOOST_STATIC_CONSTEXPR boost::enums::native_type<EnumClass>::type value = EnumClass::Enum1;
+ };
+ template <>
+ struct val<EnumClass, 2>
+ {
+ BOOST_STATIC_CONSTEXPR boost::enums::native_type<EnumClass>::type value = EnumClass::Enum2;
+ };
+ template <>
+ struct enum_traits<EnumClass>
+ : linear_enum_traiter<EnumClass>
+ {
+ };
+ } // namespace meta
+ }
+}
+
+
+
+//! OSTRREAM overloading
+template <typename OSTREAM>
+inline OSTREAM& operator <<(OSTREAM& os, EnumClass v) {
+ os << int(boost::enums::native_value(v));
+ return os;
+}
+
+#endif

Added: sandbox/enums/libs/enums/test/ExType.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/ExType.hpp 2011-03-18 19:10:57 EDT (Fri, 18 Mar 2011)
@@ -0,0 +1,91 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef EXTYPE_HPP
+#define EXTYPE_HPP
+
+
+#include <boost/enums/scoped.hpp>
+#include <boost/enums/ordinal.hpp>
+#include <cstddef>
+
+#if 1
+ BOOST_ENUM_TYPE_START(EC3, int) {
+ Enum0,
+ Enum1,
+ Enum2
+ } BOOST_ENUM_TYPE_CONS_END(EC3, int)
+#else
+
+struct EC3NS {
+ enum type {
+ Enum0,
+ Enum1,
+ Enum2
+ };
+};
+typedef boost::enums::enum_type_cons<EC3NS, unsigned char> EC3;
+#endif
+BOOST_ENUMS_SPECIALIZATIONS(EC3, int)
+
+namespace boost {
+ namespace enums {
+ namespace meta {
+
+ 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>
+ {
+ BOOST_STATIC_CONSTEXPR std::size_t value = 0;
+ };
+ template <>
+ struct pos<EC3, EC3::Enum1>
+ {
+ BOOST_STATIC_CONSTEXPR std::size_t value = 1;
+ };
+ template <>
+ struct pos<EC3, EC3::Enum2>
+ {
+ BOOST_STATIC_CONSTEXPR std::size_t value = 2;
+ };
+
+ template <>
+ struct val<EC3, 0>
+ {
+ BOOST_STATIC_CONSTEXPR boost::enums::native_type<EC3>::type value = EC3::Enum0;
+ };
+ template <>
+ struct val<EC3, 1>
+ {
+ BOOST_STATIC_CONSTEXPR boost::enums::native_type<EC3>::type value = EC3::Enum1;
+ };
+ template <>
+ struct val<EC3, 2>
+ {
+ BOOST_STATIC_CONSTEXPR boost::enums::native_type<EC3>::type value = EC3::Enum2;
+ };
+ template <>
+ struct enum_traits<EC3> : linear_enum_traiter<EC3>
+ {
+ };
+ } // namespace meta
+ }
+}
+
+#endif

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-18 19:10:57 EDT (Fri, 18 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_fail.cpp ]
 
         [ run enum_class/comparison/less_pass.cpp ]
         [ run enum_class/comparison/equal_pass.cpp ]
@@ -75,6 +75,41 @@
         [ run EnumClass.cpp odr.cpp ]
         ;
 
+ test-suite "enum_type"
+ :
+ [ compile enum_type/has_same_size_as_ut_pass.cpp : : enum_type__has_same_size_as_ut_pass ]
+ [ compile enum_type/underlying_type_pass.cpp : : enum_type__underlying_type_fail ]
+ [ compile enum_type/inside_union_no_cons_pass.cpp : : enum_type__inside_union_no_cons_pass ]
+ [ compile-fail enum_type/inside_union_cons.fail.cpp : : enum_type__inside_union_cons_fail ]
+ [ compile enum_type/inside_union_cons.pass.cpp : : enum_type__inside_union_cons_pass ]
+ [ compile-fail enum_type/enum_inside_union_cons.fail.cpp : : enum_type__enum_inside_union_cons_fail ]
+ [ compile enum_type/enum_inside_union_cons.pass.cpp : : enum_type__enum_inside_union_cons_pass ]
+
+ [ run enum_type/cons/default_to_0_pass.cpp : : : : enum_type__cons__default_to_0_pass ]
+ [ run enum_type/cons/from_enum_pass.cpp : : : : enum_type__cons__from_enum_pass ]
+ #[ compile-fail enum_type/cons/from_int_fails.cpp : : enum_type__cons__from_int_fails ]
+
+ [ run enum_type/comparison/less_pass.cpp : : : : enum_type__comparison__less_pass ]
+ [ run enum_type/comparison/equal_pass.cpp : : : : enum_type__comparison__equal_pass ]
+ [ run enum_type/comparison/not_equal_pass.cpp : : : : enum_type__comparison__not_equal_pass ]
+
+ [ compile enum_type/conversion/implicit_conversion_to_ut_pass.cpp : : enum_type__conversion__implicit_conversion_to_ut_pass ]
+ [ compile enum_type/conversion/implicit_conversion_to_bool_pass.cpp : : enum_type__conversion__implicit_conversion_to_bool_pass ]
+ [ run enum_type/conversion/explicit_conversion_from_valid_int_pass.cpp : : : : enum_type__conversion__explicit_conversion_from_valid_int_pass ]
+ [ run enum_type/conversion/explicit_conversion_from_invalid_int_fail.cpp : : : : enum_type__conversion__explicit_conversion_from_invalid_int_fail ]
+
+ [ compile enum_type/meta/first_pass.cpp : : enum_type__meta__first_pass ]
+ [ compile enum_type/meta/last_pass.cpp : : enum_type__meta__last_pass ]
+ [ compile enum_type/meta/pos_pass.cpp : : enum_type__meta__pos_pass ]
+ [ compile enum_type/meta/val_pass.cpp : : enum_type__meta__val_pass ]
+ [ compile enum_type/meta/pred_pass.cpp : : enum_type__meta__pred_pass ]
+ [ compile enum_type/meta/succ_pass.cpp : : enum_type__meta__succ_pass ]
+ [ compile-fail enum_type/meta/succ_of_last_fail.cpp : : enum_type__meta__succ_of_last_fail ]
+ [ compile-fail enum_type/meta/pred_of_first_fail.cpp : : enum_type__meta__pred_of_first_fail ]
+ [ compile-fail enum_type/meta/val_of_invalid_fail.cpp : : enum_type__meta__val_of_invalid_fail ]
+
+ ;
+
   test-suite "enum_array"
   :
         [ run enum_array/types.pass.cpp : : : : enum_array__types__pass ]

Added: sandbox/enums/libs/enums/test/enum_type/comparison/equal_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/comparison/equal_pass.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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 "./EnumType.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_type/comparison/less_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/comparison/less_pass.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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 "./EnumType.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_type/comparison/not_equal_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/comparison/not_equal_pass.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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 "./EnumType.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_type/cons/default_to_0_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/cons/default_to_0_fail.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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 "./EnumType.hpp"
+#include <boost/detail/lightweight_test.hpp>
+
+int main() {
+ using namespace boost::enums;
+
+ { // defaults to the enum default
+ EnumClass e = EnumClass() ;
+ BOOST_TEST(native_value(e)==0);
+ }
+ return boost::report_errors();
+}
+

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

Added: sandbox/enums/libs/enums/test/enum_type/cons/from_enum_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/cons/from_enum_pass.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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 "./EnumType.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_type/cons/from_int_fails.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/cons/from_int_fails.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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 "./EnumType.hpp"
+
+void fail() {
+
+ // Construction from int compile fails
+ EnumClass e(0);
+ (void)e;
+
+}

Added: sandbox/enums/libs/enums/test/enum_type/conversion/explicit_conversion_from_invalid_int_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/conversion/explicit_conversion_from_invalid_int_fail.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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 "./EnumType.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)(native_value(e))==(unsigned char)(6));
+ }
+
+ return boost::report_errors();
+}

Added: sandbox/enums/libs/enums/test/enum_type/conversion/explicit_conversion_from_valid_int_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/conversion/explicit_conversion_from_valid_int_pass.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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 "./EnumType.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_type/conversion/implicit_conversion_to_bool_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/conversion/implicit_conversion_to_bool_pass.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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 "./EnumType.hpp"
+
+void fail() {
+
+ { // The wrapper can be used on a if (is convertible to bool)
+ EnumClass e;
+ bool b = e;
+ if (e)
+ b=false;
+ }
+
+}

Added: sandbox/enums/libs/enums/test/enum_type/conversion/implicit_conversion_to_ut_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/conversion/implicit_conversion_to_ut_pass.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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 "./EnumType.hpp"
+
+void f(int ) {
+}
+
+void fail() {
+
+ { // The wrapper is implicit convertible to underlying int
+ EnumClass e ;
+ f(e);
+ int i = e;
+ (void)i;
+ }
+
+}

Added: sandbox/enums/libs/enums/test/enum_type/enum_inside_union_cons.fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/enum_inside_union_cons.fail.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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/scoped.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_type/enum_inside_union_cons.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/enum_inside_union_cons.pass.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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/scoped.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_type/has_same_size_as_ut_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/has_same_size_as_ut_pass.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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 "./EnumType.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_type/inside_union_cons.fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/inside_union_cons.fail.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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/scoped.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_type/inside_union_cons.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/inside_union_cons.pass.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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/scoped.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_type/inside_union_no_cons_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/inside_union_no_cons_pass.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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/scoped.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;
+
+}

Added: sandbox/enums/libs/enums/test/enum_type/meta/first_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/meta/first_pass.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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 "./EnumType.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_type/meta/last_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/meta/last_pass.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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 "./EnumType.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_type/meta/pos_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/meta/pos_pass.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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 "./EnumType.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_type/meta/pred_of_first_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/meta/pred_of_first_fail.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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 "./EnumType.hpp"
+#include <boost/enums/ordinal/pred.hpp>
+#include <boost/enums/scoped/native_type.hpp>
+
+void fail() {
+ using namespace boost::enums;
+
+ {
+ native_type<EnumClass>::type e = meta::pred<EnumClass, EnumClass::Default>::value;
+ }
+
+}

Added: sandbox/enums/libs/enums/test/enum_type/meta/pred_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/meta/pred_pass.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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 "./EnumType.hpp"
+#include <boost/static_assert.hpp>
+#include <boost/enums/ordinal/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_type/meta/size_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/meta/size_pass.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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 "./EnumType.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_type/meta/succ_of_last_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/meta/succ_of_last_fail.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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 "./EnumType.hpp"
+#include <boost/enums/ordinal/succ.hpp>
+#include <boost/enums/scoped/native_type.hpp>
+
+void fail() {
+ using namespace boost::enums;
+
+ {
+ native_type<EnumClass>::type e = meta::succ<EnumClass, EnumClass::Enum2>::value ;
+ }
+
+}

Added: sandbox/enums/libs/enums/test/enum_type/meta/succ_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/meta/succ_pass.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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 "./EnumType.hpp"
+#include <boost/static_assert.hpp>
+#include <boost/enums/ordinal/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_type/meta/val_of_invalid_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/meta/val_of_invalid_fail.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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 "./EnumType.hpp"
+#include <boost/static_assert.hpp>
+
+void fail() {
+ using namespace boost::enums;
+
+ { // has the same size as the underlying type
+ native_type<EnumClass>::type e= meta::val<EnumClass,3>::value;
+ (void)(e);
+ }
+
+}

Added: sandbox/enums/libs/enums/test/enum_type/meta/val_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/meta/val_pass.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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 "./EnumType.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_type/underlying_type_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/enums/libs/enums/test/enum_type/underlying_type_pass.cpp 2011-03-18 19:10:57 EDT (Fri, 18 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 "./EnumType.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