Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r78407 - in trunk/boost: detail thread thread/detail
From: anthony_at_[hidden]
Date: 2012-05-10 13:06:16


Author: anthonyw
Date: 2012-05-10 13:06:15 EDT (Thu, 10 May 2012)
New Revision: 78407
URL: http://svn.boost.org/trac/boost/changeset/78407

Log:
Combine scoped enum emulation from thread library into detail/scoped_enum_emulation.hpp
Removed:
   trunk/boost/thread/detail/scoped_enum.hpp
Text files modified:
   trunk/boost/detail/scoped_enum_emulation.hpp | 110 +++++++++++++++++++++++++++++++++++++--
   trunk/boost/thread/cv_status.hpp | 2
   trunk/boost/thread/future.hpp | 2
   3 files changed, 106 insertions(+), 8 deletions(-)

Modified: trunk/boost/detail/scoped_enum_emulation.hpp
==============================================================================
--- trunk/boost/detail/scoped_enum_emulation.hpp (original)
+++ trunk/boost/detail/scoped_enum_emulation.hpp 2012-05-10 13:06:15 EDT (Thu, 10 May 2012)
@@ -1,6 +1,8 @@
 // scoped_enum_emulation.hpp ---------------------------------------------------------//
 
 // Copyright Beman Dawes, 2009
+// Copyright (C) 2012 Vicente J. Botet Escriba
+// Copyright (C) 2012 Anthony Williams
 
 // Distributed under the Boost Software License, Version 1.0.
 // See http://www.boost.org/LICENSE_1_0.txt
@@ -38,19 +40,115 @@
 #define BOOST_SCOPED_ENUM_EMULATION_HPP
 
 #include <boost/config.hpp>
+#include <boost/detail/workaround.hpp>
+
+namespace boost
+{
+
+#ifdef BOOST_NO_SCOPED_ENUMS
+ template <typename EnumType>
+ struct underlying_type
+ {
+ typedef typename EnumType::underlying_type type;
+ };
+
+ template <typename UnderlyingType, typename EnumType>
+ UnderlyingType underlying_cast(EnumType v)
+ {
+ return v.underlying();
+ }
+
+ template <typename EC>
+ inline
+ typename EC::enum_type native_value(EC e)
+ {
+ return e.native();
+ }
+
+#else // BOOST_NO_SCOPED_ENUMS
+
+ template <typename EnumType>
+ struct underlying_type
+ {
+ //typedef typename std::underlying_type<EnumType>::type type;
+ };
+
+ template <typename UnderlyingType, typename EnumType>
+ UnderlyingType underlying_cast(EnumType v)
+ {
+ return static_cast<UnderlyingType>(v);
+ }
+
+ template <typename EC>
+ inline
+ EC native_value(EC e)
+ {
+ return e;
+ }
+
+#endif
+}
+
 
 #ifdef BOOST_NO_SCOPED_ENUMS
 
-# define BOOST_SCOPED_ENUM_START(name) struct name { enum enum_type
-# define BOOST_SCOPED_ENUM_END };
-# define BOOST_SCOPED_ENUM(name) name::enum_type
+#ifndef BOOST_NO_EXPLICIT_CONVERSION_OPERATORS
+
+#define BOOST_SCOPED_ENUM_UT_DECLARE_CONVERSION_OPERATOR \
+ explicit operator underlying_type() const { return underlying(); }
 
 #else
 
-# define BOOST_SCOPED_ENUM_START(name) enum class name
-# define BOOST_SCOPED_ENUM_END
-# define BOOST_SCOPED_ENUM(name) name
+#define BOOST_SCOPED_ENUM_UT_DECLARE_CONVERSION_OPERATOR
 
 #endif
 
+#define BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(EnumType, UnderlyingType) \
+ struct EnumType { \
+ typedef UnderlyingType underlying_type; \
+ EnumType() {} \
+ explicit EnumType(underlying_type v) : v_(v) {} \
+ underlying_type underlying() const { return v_; } \
+ BOOST_SCOPED_ENUM_UT_DECLARE_CONVERSION_OPERATOR \
+ private: \
+ underlying_type v_; \
+ typedef EnumType self_type; \
+ public: \
+ enum enum_type
+
+#define BOOST_SCOPED_ENUM_DECLARE_END2() \
+ enum_type native() const { return enum_type(v_); } \
+ friend bool operator ==(self_type lhs, enum_type rhs) { return enum_type(lhs.v_)==rhs; } \
+ friend bool operator ==(enum_type lhs, self_type rhs) { return lhs==enum_type(rhs.v_); } \
+ friend bool operator !=(self_type lhs, enum_type rhs) { return enum_type(lhs.v_)!=rhs; } \
+ friend bool operator !=(enum_type lhs, self_type rhs) { return lhs!=enum_type(rhs.v_); } \
+ };
+
+#define BOOST_SCOPED_ENUM_DECLARE_END(EnumType) \
+ ; \
+ EnumType(enum_type v) : v_(v) {} \
+ BOOST_SCOPED_ENUM_DECLARE_END2()
+
+#define BOOST_SCOPED_ENUM_DECLARE_BEGIN(EnumType) \
+ BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(EnumType,int)
+
+#define BOOST_SCOPED_ENUM_NATIVE(EnumType) EnumType::enum_type
+#define BOOST_SCOPED_ENUM_FORWARD_DECLARE(EnumType) struct EnumType
+
+#else // BOOST_NO_SCOPED_ENUMS
+
+#define BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(EnumType,UnderlyingType) enum class EnumType:UnderlyingType
+#define BOOST_SCOPED_ENUM_DECLARE_BEGIN(EnumType) enum class EnumType
+#define BOOST_SCOPED_ENUM_DECLARE_END2()
+#define BOOST_SCOPED_ENUM_DECLARE_END(EnumType) ;
+
+#define BOOST_SCOPED_ENUM_NATIVE(EnumType) EnumType
+#define BOOST_SCOPED_ENUM_FORWARD_DECLARE(EnumType) enum class EnumType
+
+#endif // BOOST_NO_SCOPED_ENUMS
+
+#define BOOST_SCOPED_ENUM_START(name) BOOST_SCOPED_ENUM_DECLARE_BEGIN(name)
+#define BOOST_SCOPED_ENUM_END BOOST_SCOPED_ENUM_DECLARE_END2()
+#define BOOST_SCOPED_ENUM(name) BOOST_SCOPED_ENUM_NATIVE(name)
+
 #endif // BOOST_SCOPED_ENUM_EMULATION_HPP

Modified: trunk/boost/thread/cv_status.hpp
==============================================================================
--- trunk/boost/thread/cv_status.hpp (original)
+++ trunk/boost/thread/cv_status.hpp 2012-05-10 13:06:15 EDT (Thu, 10 May 2012)
@@ -9,7 +9,7 @@
 #ifndef BOOST_THREAD_CV_STATUS_HPP
 #define BOOST_THREAD_CV_STATUS_HPP
 
-#include <boost/thread/detail/scoped_enum.hpp>
+#include <boost/detail/scoped_enum_emulation.hpp>
 
 namespace boost
 {

Deleted: trunk/boost/thread/detail/scoped_enum.hpp
==============================================================================
--- trunk/boost/thread/detail/scoped_enum.hpp 2012-05-10 13:06:15 EDT (Thu, 10 May 2012)
+++ (empty file)
@@ -1,112 +0,0 @@
-// Copyright (C) 2012 Vicente J. Botet Escriba
-//
-// 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)
-
-#ifndef BOOST_THREAD_DETAIL_SCOPED_ENUM_HPP
-#define BOOST_THREAD_DETAIL_SCOPED_ENUM_HPP
-
-#include <boost/config.hpp>
-#include <boost/detail/workaround.hpp>
-
-namespace boost
-{
-
-#ifdef BOOST_NO_SCOPED_ENUMS
- template <typename NT>
- struct underlying_type
- {
- typedef typename NT::underlying_type type;
- };
-
- template <typename UT, typename NT>
- UT underlying_cast(NT v)
- {
- return v.underlying();
- }
-
- template <typename EC>
- inline
- typename EC::enum_type native_value(EC e)
- {
- return e.native();
- }
-
-#else // BOOST_NO_SCOPED_ENUMS
-
- template <typename NT>
- struct underlying_type
- {
- //typedef typename std::underlying_type<NT>::type type;
- };
-
- template <typename UT, typename NT>
- UT underlying_cast(NT v)
- {
- return static_cast<UT>(v);
- }
-
- template <typename EC>
- inline
- EC native_value(EC e)
- {
- return e;
- }
-
-#endif
-}
-
-
-#ifdef BOOST_NO_SCOPED_ENUMS
-
-#ifndef BOOST_NO_EXPLICIT_CONVERSION_OPERATORS
-
-#define BOOST_SCOPED_ENUM_UT_DECLARE_CONVERSION_OPERATOR \
- explicit operator underlying_type() const { return underlying(); }
-
-#else
-
-#define BOOST_SCOPED_ENUM_UT_DECLARE_CONVERSION_OPERATOR
-
-#endif
-
-#define BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(NT, UT) \
- struct NT { \
- typedef UT underlying_type; \
- enum enum_type
-
-#define BOOST_SCOPED_ENUM_DECLARE_END(NT) \
- ; \
- NT() {} \
- NT(enum_type v) : v_(v) {} \
- explicit NT(underlying_type v) : v_(v) {} \
- underlying_type underlying() const { return v_; } \
- enum_type native() const { return enum_type(v_); } \
- BOOST_SCOPED_ENUM_UT_DECLARE_CONVERSION_OPERATOR \
- friend bool operator ==(NT lhs, enum_type rhs) { return enum_type(lhs.v_)==rhs; } \
- friend bool operator ==(enum_type lhs, NT rhs) { return lhs==enum_type(rhs.v_); } \
- friend bool operator !=(NT lhs, enum_type rhs) { return enum_type(lhs.v_)!=rhs; } \
- friend bool operator !=(enum_type lhs, NT rhs) { return lhs!=enum_type(rhs.v_); } \
- private: \
- underlying_type v_; \
- };
-
-#define BOOST_SCOPED_ENUM_DECLARE_BEGIN(NT) \
- BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(NT,int)
-
-#define BOOST_SCOPED_ENUM_NATIVE(NT) NT::enum_type
-#define BOOST_SCOPED_ENUM_FORWARD_DECLARE(NT) struct NT
-
-#else // BOOST_NO_SCOPED_ENUMS
-
-#define BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(NT,UT) enum class NT:UT
-#define BOOST_SCOPED_ENUM_DECLARE_BEGIN(NT) enum class NT
-#define BOOST_SCOPED_ENUM_DECLARE_END(NT) ;
-
-#define BOOST_SCOPED_ENUM_NATIVE(NT) NT
-#define BOOST_SCOPED_ENUM_FORWARD_DECLARE(NT) enum class NT
-
-#endif // BOOST_NO_SCOPED_ENUMS
-
-
-#endif // BOOST_THREAD_DETAIL_SCOPED_ENUM_HPP

Modified: trunk/boost/thread/future.hpp
==============================================================================
--- trunk/boost/thread/future.hpp (original)
+++ trunk/boost/thread/future.hpp 2012-05-10 13:06:15 EDT (Thu, 10 May 2012)
@@ -9,7 +9,7 @@
 #define BOOST_THREAD_FUTURE_HPP
 
 #include <boost/thread/detail/config.hpp>
-#include <boost/thread/detail/scoped_enum.hpp>
+#include <boost/detail/scoped_enum_emulation.hpp>
 #include <stdexcept>
 #include <boost/thread/detail/move.hpp>
 #include <boost/thread/thread_time.hpp>


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