Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51715 - trunk/boost/detail
From: bdawes_at_[hidden]
Date: 2009-03-11 16:19:28


Author: bemandawes
Date: 2009-03-11 16:19:27 EDT (Wed, 11 Mar 2009)
New Revision: 51715
URL: http://svn.boost.org/trac/boost/changeset/51715

Log:
Initial commit.
Added:
   trunk/boost/detail/scoped_enum_emulation.hpp (contents, props changed)

Added: trunk/boost/detail/scoped_enum_emulation.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/detail/scoped_enum_emulation.hpp 2009-03-11 16:19:27 EDT (Wed, 11 Mar 2009)
@@ -0,0 +1,52 @@
+// scoped_enum_emulation.hpp ---------------------------------------------------------//
+
+// Copyright Beman Dawes, 2009
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Generates C++0x scoped enums if the feature is present, otherwise emulates C++0x
+// scoped enums with C++03 namespaces and enums. The Boost.Config BOOST_NO_SCOPED_ENUMS
+// macro is used to detect feature support.
+//
+// See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2347.pdf for a
+// description of the scoped enum feature. Note that the committee changed the name
+// from strongly typed enum to scoped enum.
+//
+// Caution: only the syntax is emulated; the semantics are not emulated and
+// the syntax emulation doesn't include being able to specify the underlying
+// representation type.
+//
+// The emulation is via struct rather than namespace to allow use within classes.
+// Thanks to Andrey Semashev for pointing that out.
+//
+// Sample usage:
+//
+// BOOST_SCOPED_ENUM_START(algae) { green, red, cyan }; BOOST_SCOPED_ENUM_END
+// ...
+// BOOST_SCOPED_ENUM(algae) sample( algae::red );
+// void foo( BOOST_SCOPED_ENUM(algae) color );
+// ...
+// sample = algae::green;
+// foo( algae::cyan );
+
+#ifndef BOOST_SCOPED_ENUM_EMULATION_HPP
+#define BOOST_SCOPED_ENUM_EMULATION_HPP
+
+#include <boost/config.hpp>
+
+#ifdef BOOST_NO_SCOPED_ENUMS
+
+# define BOOST_SCOPED_ENUM_START(name) struct name { enum enum_t
+# define BOOST_SCOPED_ENUM_END };
+# define BOOST_SCOPED_ENUM(name) name::enum_t
+
+#else
+
+# define BOOST_SCOPED_ENUM_START(name) enum class name
+# define BOOST_SCOPED_ENUM_END
+# define BOOST_SCOPED_ENUM(name) name
+
+#endif
+
+#endif // BOOST_SCOPED_ENUM_EMULATION_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