|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r70091 - in sandbox/enums/boost/enums: . containers mpl mpl/aux_/enum_range_c ordinal scoped
From: vicente.botet_at_[hidden]
Date: 2011-03-17 19:21:28
Author: viboes
Date: 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
New Revision: 70091
URL: http://svn.boost.org/trac/boost/changeset/70091
Log:
Enums: most of the files moved to subdirs
Added:
sandbox/enums/boost/enums/containers.hpp (contents, props changed)
sandbox/enums/boost/enums/containers/enum_array.hpp (contents, props changed)
sandbox/enums/boost/enums/containers/enum_range.hpp (contents, props changed)
sandbox/enums/boost/enums/containers/enum_set.hpp (contents, props changed)
sandbox/enums/boost/enums/ordinal.hpp (contents, props changed)
sandbox/enums/boost/enums/ordinal/first.hpp (contents, props changed)
sandbox/enums/boost/enums/ordinal/last.hpp (contents, props changed)
sandbox/enums/boost/enums/ordinal/linear_traiter.hpp (contents, props changed)
sandbox/enums/boost/enums/ordinal/pos.hpp (contents, props changed)
sandbox/enums/boost/enums/ordinal/pred.hpp (contents, props changed)
sandbox/enums/boost/enums/ordinal/size.hpp (contents, props changed)
sandbox/enums/boost/enums/ordinal/succ.hpp (contents, props changed)
sandbox/enums/boost/enums/ordinal/traits.hpp (contents, props changed)
sandbox/enums/boost/enums/ordinal/val.hpp (contents, props changed)
sandbox/enums/boost/enums/scoped.hpp (contents, props changed)
sandbox/enums/boost/enums/scoped/default_value.hpp (contents, props changed)
sandbox/enums/boost/enums/scoped/emulation.hpp (contents, props changed)
sandbox/enums/boost/enums/scoped/enum_class_cons.hpp (contents, props changed)
sandbox/enums/boost/enums/scoped/enum_class_no_cons.hpp (contents, props changed)
sandbox/enums/boost/enums/scoped/enum_type_cons.hpp (contents, props changed)
sandbox/enums/boost/enums/scoped/enum_type_no_cons.hpp (contents, props changed)
sandbox/enums/boost/enums/scoped/native_type.hpp (contents, props changed)
sandbox/enums/boost/enums/scoped/native_value.hpp (contents, props changed)
sandbox/enums/boost/enums/scoped/scoping_type.hpp (contents, props changed)
sandbox/enums/boost/enums/scoped/underlying_type.hpp (contents, props changed)
sandbox/enums/boost/enums/scoped/underlying_value.hpp (contents, props changed)
Removed:
sandbox/enums/boost/enums/default_value.hpp
sandbox/enums/boost/enums/emulation.hpp
sandbox/enums/boost/enums/enum_array.hpp
sandbox/enums/boost/enums/enum_class_cons.hpp
sandbox/enums/boost/enums/enum_class_macro.hpp
sandbox/enums/boost/enums/enum_class_no_cons.hpp
sandbox/enums/boost/enums/enum_range.hpp
sandbox/enums/boost/enums/enum_set.hpp
sandbox/enums/boost/enums/enum_traiter.hpp
sandbox/enums/boost/enums/enum_traits.hpp
sandbox/enums/boost/enums/enum_type.hpp
sandbox/enums/boost/enums/enum_type_cons.hpp
sandbox/enums/boost/enums/enum_type_no_cons.hpp
sandbox/enums/boost/enums/enum_value.hpp
sandbox/enums/boost/enums/first.hpp
sandbox/enums/boost/enums/get_value.hpp
sandbox/enums/boost/enums/last.hpp
sandbox/enums/boost/enums/pos.hpp
sandbox/enums/boost/enums/pred.hpp
sandbox/enums/boost/enums/scoping_type.hpp
sandbox/enums/boost/enums/size.hpp
sandbox/enums/boost/enums/succ.hpp
sandbox/enums/boost/enums/underlying_type.hpp
sandbox/enums/boost/enums/underlying_value.hpp
sandbox/enums/boost/enums/val.hpp
Text files modified:
sandbox/enums/boost/enums/enum_subrange.hpp | 8 ++++----
sandbox/enums/boost/enums/enum_subrange_traiter.hpp | 8 ++++----
sandbox/enums/boost/enums/include.hpp | 21 ++++-----------------
sandbox/enums/boost/enums/mpl/aux_/enum_range_c/iterator.hpp | 4 ++--
sandbox/enums/boost/enums/mpl/enum_c.hpp | 4 ++--
sandbox/enums/boost/enums/mpl/enum_range_c.hpp | 4 ++--
6 files changed, 18 insertions(+), 31 deletions(-)
Added: sandbox/enums/boost/enums/containers.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/containers.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -0,0 +1,20 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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 BOOST_ENUMS_CONTAINERS_HPP
+#define BOOST_ENUMS_CONTAINERS_HPP
+
+#include <boost/enums/containers/range.hpp>
+#include <boost/enums/containers/set.hpp>
+#include <boost/enums/containers/array.hpp>
+
+#endif // BOOST_ENUMS_CONTAINERS_HPP
Added: sandbox/enums/boost/enums/containers/enum_array.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/containers/enum_array.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -0,0 +1,488 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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)
+//
+// Based on the boost/array.hpp implementation
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/*!
+\file
+\brief
+The header \c <boost/enums/containers/enum_array.hpp> defines a class template for storing
+sequences of objects fixed by the size of the enumeration.
+We can say that
+\c enum_array is the counterpart of \c std::array when the index are enums.
+*/
+
+#ifndef BOOST_ENUMS_CONTAINER_ENUM_ARRAY_HPP
+#define BOOST_ENUMS_CONTAINER_ENUM_ARRAY_HPP
+
+#include <boost/detail/workaround.hpp>
+
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+# pragma warning(push)
+# pragma warning(disable:4996) // 'std::equal': Function call with parameters that may be unsafe
+# pragma warning(disable:4510) // boost::enums::enum_array<T,EC>' : default constructor could not be generated
+# pragma warning(disable:4610) // warning C4610: class 'boost::enums::enum_array<T,EC>' can never be instantiated - user defined constructor required
+#endif
+
+#include <cstddef>
+#include <stdexcept>
+#include <boost/assert.hpp>
+#include <boost/swap.hpp>
+
+// Handles broken standard libraries better than <iterator>
+#include <boost/detail/iterator.hpp>
+#include <boost/throw_exception.hpp>
+#include <algorithm>
+
+#include <boost/enums/ordinal/size.hpp>
+#include <boost/enums/ordinal/pos.hpp>
+#include <boost/type_traits/integral_constant.hpp>
+
+// FIXES for broken compilers + CONSTEXPR
+#include <boost/config.hpp>
+
+namespace boost
+{
+ namespace enums
+ {
+
+ /*!
+ An \c enum_array supports random access iterators. An instance of \c enum_array<T, EC>
+ stores as many elements of type \c T as enum literals are on the enum class \c EC,
+ so that <tt>size() == meta::size<EC>::value</tt> is an invariant.
+
+ The elements of an \c enum_array are stored contiguously, meaning that if \c a is an
+ \c enum_array<T, EC>, then it obeys the identity
+
+ \code
+ &a[n] == &a[0] + n for all 0 <= n < meta::size<EC>::value.
+ \endcode
+
+ An \c enum_array is an aggregate that can (????) be initialized with the syntax
+
+ \code
+ enum_array<T, EC> a = { initializer-list };
+ \endcode
+
+ where \e initializer-list is a comma separated list of up to \c meta::size<EC>::value
+ elements whose types are convertible to \c T.
+
+ An \c enum_array satisfies all of the requirements of a container and of a
+ reversible container, except that a default constructed array object is not
+ empty and that swap does not have constant complexity. An \c enum_array satisfies
+ some of the requirements of a sequence container. Descriptions are provided
+ here only for operations on enum_array that are not described in one of these
+ tables and for operations where there is additional semantic information.
+
+ The conditions for an aggregate are met. Class enum_array relies on
+ the implicitly-declared special member functions to conform to the
+ container requirements
+
+
+
+ \note The member variable elems is shown for exposition only, to emphasize
+ that enum_array is a class aggregate. The name elems is not part of
+ enum_array's interface
+
+ \param T array's element type
+ \param EC array's index enumeration class
+ */
+
+ template<class T, typename EC>
+ class enum_array {
+ public:
+ //! // exposition only
+ T elems[meta::size<EC>::value]; // fixed-size array of elements of type T
+
+ public:
+ // type definitions
+ typedef T value_type;
+ typedef T* iterator;
+ typedef const T* const_iterator;
+ typedef T& reference;
+ typedef const T& const_reference;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef EC key_type;
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+ static const std::size_t static_size = meta::size<EC>::value;
+ //enum_array() {}
+
+ // iterator support
+ //! \returns iterator for the first element
+ //! \throws Nothing
+ iterator begin() { return elems; }
+
+ //! \returns const iterator for the first element
+ //! \throws Nothing
+ const_iterator begin() const { return elems; }
+ const_iterator cbegin() const { return elems; }
+
+ //! \returns iterator for position after the last element
+ //! \throws Nothing
+ iterator end() { return elems+static_size; }
+
+ //! \returns const iterator for position after the last element
+ //! \throws Nothing
+ const_iterator end() const { return elems+static_size; }
+ const_iterator cend() const { return elems+static_size; }
+
+ // reverse iterator support
+#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS)
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+#elif defined(_MSC_VER) && (_MSC_VER == 1300) && defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB == 310)
+ // workaround for broken reverse_iterator in VC7
+ typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, iterator,
+ reference, iterator, reference> > reverse_iterator;
+ typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, const_iterator,
+ const_reference, iterator, reference> > const_reverse_iterator;
+#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC)
+ typedef std::reverse_iterator<iterator, std::random_access_iterator_tag,
+ value_type, reference, iterator, difference_type> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator, std::random_access_iterator_tag,
+ value_type, const_reference, const_iterator, difference_type> const_reverse_iterator;
+#else
+ // workaround for broken reverse_iterator implementations
+ typedef std::reverse_iterator<iterator,T> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator,T> const_reverse_iterator;
+#endif
+
+ //! \returns reverse iterator for the first element of reverse iteration
+ reverse_iterator rbegin() {
+ return reverse_iterator(end());
+ }
+ const_reverse_iterator rbegin() const {
+ return const_reverse_iterator(end());
+ }
+ const_reverse_iterator crbegin() const {
+ return const_reverse_iterator(end());
+ }
+
+ //! \returns reverse iterator for position after the last element in reverse iteration
+ reverse_iterator rend() {
+ return reverse_iterator(begin());
+ }
+ const_reverse_iterator rend() const {
+ return const_reverse_iterator(begin());
+ }
+ const_reverse_iterator crend() const {
+ return const_reverse_iterator(begin());
+ }
+
+ // operator[]
+ //! Requires: k'pos < static_size
+ //! \returns reference to the element with key k
+ //! \throws Nothing.
+ reference operator[](key_type k)
+ {
+ size_type i = pos(k);
+ BOOST_ASSERT( i < static_size && "out of range" );
+ return elems[i];
+ }
+
+ //! Requires: k'pos < static_size
+ //! \returns constant reference to the element with key k
+ //! \throws Nothing.
+ const_reference operator[](key_type k) const
+ {
+ size_type i = pos(k);
+ BOOST_ASSERT( i < static_size && "out of range" );
+ return elems[i];
+ }
+
+ // at() with range check
+ //! \returns element with key k
+ //! \throws std::range_error if i >= static_size
+ reference at(key_type k)
+ {
+ size_type i = rangecheck(k);
+ return elems[i];
+ }
+ const_reference at(key_type k) const
+ {
+ size_type i = rangecheck(k);
+ return elems[i];
+ }
+
+ // front() and back()
+ //! \returns reference to the first element
+ //! \throws Nothing
+ reference front()
+ {
+ return elems[0];
+ }
+
+ //! \returns const reference to the first element
+ //! \throws Nothing
+ const_reference front() const
+ {
+ return elems[0];
+ }
+
+ //! \returns reference to the last element
+ //! \throws Nothing
+ reference back()
+ {
+ return elems[static_size-1];
+ }
+
+ //! \returns const reference to the last element
+ //! \throws Nothing
+ const_reference back() const
+ {
+ return elems[static_size-1];
+ }
+
+ // size is constant
+ //! \returns linear in meta::size<EC>::value.
+ BOOST_CONSTEXPR size_type size()
+ {
+ return static_size;
+ }
+ //! \returns false
+ //! \throws Nothing
+ static bool empty()
+ {
+ return false;
+ }
+
+ //! \returns linear in meta::size<EC>::value.
+ BOOST_CONSTEXPR size_type max_size()
+ {
+ return static_size;
+ }
+
+
+ /*! Effects: swap_ranges(begin(), end(), y.begin())
+ \throws Nothing unless one of the element-wise swap calls throws an exception.
+ Note: Unlike the swap function for other containers, enum_array::swap
+ takes linear time, may exit via an exception, and does not cause
+ iterators to become associated with the other container.
+ */
+ void swap (enum_array<T,EC>& y)
+ {
+ for (size_type i = 0; i < static_size; ++i)
+ boost::swap(elems[i],y.elems[i]);
+ }
+
+ // direct access to data (read-only)
+
+ //! \returns elems.
+ const T* data() const {
+ return elems;
+ }
+ //! \returns elems.
+ T* data() {
+ return elems;
+ }
+
+ // use enum_array as C array (direct read/write access to data)
+ T* c_array() {
+ return elems;
+ }
+
+ // assignment with type conversion
+ template <typename T2>
+ enum_array<T,EC>& operator= (const enum_array<T2,EC>& rhs) {
+ std::copy(rhs.begin(),rhs.end(), begin());
+ return *this;
+ }
+
+ // A synonym for fill
+ // assign one value to all elements
+ //! Effects: std::fill_n(begin(), static_size, value)
+ void assign (const T& value) {
+ fill ( value );
+ }
+
+ //! Effects: fill_n(begin(), static_size, u)
+ void fill (const T& value)
+ {
+ std::fill_n(begin(),size(),value);
+ }
+
+ // check range (may be private because it is static)
+ static size_type rangecheck (key_type k) {
+ size_type i = enums::pos(k);
+ if (i >= static_size) {
+ std::out_of_range e("array<>: index out of range");
+ boost::throw_exception(e);
+ }
+ return i;
+ }
+
+ };
+
+
+
+ // comparisons
+ //! \returns std::equal(x.begin(), x.end(), y.begin())
+ template<class T, typename EC>
+ bool operator== (const enum_array<T,EC>& x, const enum_array<T,EC>& y)
+ {
+ return std::equal(x.begin(), x.end(), y.begin());
+ }
+
+ //! \returns std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end())
+ template<class T, typename EC>
+ bool operator< (const enum_array<T,EC>& x, const enum_array<T,EC>& y)
+ {
+ return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end());
+ }
+
+ //! \returns !(x == y)
+ template<class T, typename EC>
+ bool operator!= (const enum_array<T,EC>& x, const enum_array<T,EC>& y)
+ {
+ return !(x==y);
+ }
+
+ //! \returns y < x
+ template<class T, typename EC>
+ bool operator> (const enum_array<T,EC>& x, const enum_array<T,EC>& y)
+ {
+ return y<x;
+ }
+ //! \returns !(y<x)
+ template<class T, typename EC>
+ bool operator<= (const enum_array<T,EC>& x, const enum_array<T,EC>& y)
+ {
+ return !(y<x);
+ }
+ //! \returns !(x<y)
+ template<class T, typename EC>
+ bool operator>= (const enum_array<T,EC>& x, const enum_array<T,EC>& y)
+ {
+ return !(x<y);
+ }
+
+ //! enum_array's swap
+
+ //! <b>Effects:</b> As
+ //! \code
+ //! x.swap(y);
+ //! \endcode
+ //! <b>Complexity:</b> linear in \c meta::size<EC>::value.
+
+ template<class T, typename EC>
+ inline void swap (enum_array<T,EC>& x, enum_array<T,EC>& y)
+ {
+ x.swap(y);
+ }
+
+#if defined(__SUNPRO_CC)
+// Trac ticket #4757; the Sun Solaris compiler can't handle
+// syntax like 'T(&get_c_array(boost::array<T,static_size>& arg))[static_size]'
+//
+// We can't just use this for all compilers, because the
+// borland compilers can't handle this form.
+ namespace detail {
+ template <typename T, typename EC> struct c_array
+ {
+ typedef T type[meta::size];
+ };
+ }
+
+ // Specific for boost::enums::enum_array: simply returns its elems data member.
+ template <typename T, typename EC>
+ typename detail::c_array<T,static_size>::type& get_c_array(enum_array<T,EC>& arg)
+ {
+ return arg.elems;
+ }
+
+ // Specific for boost::enums::enum_array: simply returns its elems data member.
+ template <typename T, typename EC>
+ typename const detail::c_array<T,static_size>::type& get_c_array(const enum_array<T,EC>& arg)
+ {
+ return arg.elems;
+ }
+#else
+ template <typename T, typename EC>
+ T(&get_c_array(enum_array<T,EC>& arg))[meta::size<EC>::value]
+ {
+ //! c_array conversion.
+ return arg.elems;
+ }
+
+ template <typename T, typename EC>
+ const T(&get_c_array(const enum_array<T,EC>& arg))[meta::size<EC>::value]
+ {
+ //! c_array const conversion.
+ return arg.elems;
+ }
+#endif
+
+#if 0
+
+ template <class T, typename EC>
+ class tuple_size<enum_array<T, EC> >
+ : public integral_constant<size_t, meta::size<EC>::value>
+ {};
+
+ template <class T, typename EC>
+ class tuple_size<const enum_array<T, EC> >
+ : public integral_constant<size_t, meta::size<EC>::value>
+ {};
+
+ template <class T, typename EC, enum_type<EC>::type K>
+ class tuple_element<enum_array<T, EC> >
+ {
+ public:
+ typedef T type;
+ };
+
+ template <class T, typename EC, enum_type<EC>::type K>
+ class tuple_element<const enum_array<T, EC> >
+ {
+ public:
+ typedef const T type;
+ };
+
+ template <class T, typename EC, enum_type<EC>::type K>
+ inline
+ T&
+ get(enum_array<T, EC>& a)
+ {
+ return a[K];
+ }
+
+ template <class T, typename EC, enum_type<EC>::type K>
+ inline
+ const T&
+ get(const enum_array<T, EC>& a)
+ {
+ return a[K];
+ }
+
+ #ifndef BOOST_NO_RVALUE_REFERENCES
+
+ template <class T, typename EC, enum_type<EC>::type K>
+ T&&
+ get(array<T, meta::size<EC>::value>&& a)
+ {
+ return boost::move(a[K]);
+ }
+
+ #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+
+} /* namespace enums */
+} /* namespace boost */
+
+
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+# pragma warning(pop)
+#endif
+
+#endif // BOOST_ENUMS_CONTAINER_ENUM_ARRAY_HPP
Added: sandbox/enums/boost/enums/containers/enum_range.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/containers/enum_range.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -0,0 +1,162 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/*!
+ \file
+ \brief
+ The header \c <boost/enums/©enum_range.hpp> defines a class template \c enum_range for viewing an enumerations as a range.
+ */
+
+#ifndef BOOST_ENUMS_CONTAINERS_ENUM_RANGE_HPP
+#define BOOST_ENUMS_CONTAINERS_ENUM_RANGE_HPP
+
+#include <boost/enums/scoped/native_type.hpp>
+#include <boost/enums/ordinal/val.hpp>
+#include <boost/enums/ordinal/pos.hpp>
+#include <boost/enums/ordinal/size.hpp>
+
+
+#include <boost/iterator/iterator_facade.hpp>
+#include <boost/range/iterator_range.hpp>
+
+namespace boost {
+ namespace enums {
+ #ifndef BOOST_ENUMS_DOXYGEN_INVOKED
+ namespace enums_detail {
+ // enum_iterator is an iterator over an enum that
+ // is bounded only by the limits of the enum.
+ //
+ // This is useful for implementing the enum_range<E>()
+ // function.
+ //
+ // Note:
+ // This use of this iterator and enum_range<E>() is appreciably less
+ // performant than the corresponding hand-written integer
+ // loop on many compilers.
+
+ //! enum_iterator is a model of RandomAccessIterator
+ template<typename EC /* , typename Traits=enum_range_traits<EC> */ >
+ class enum_iterator
+ : public boost::iterator_facade<
+ enum_iterator<EC>,
+ EC,
+ boost::random_access_traversal_tag,
+ EC,
+ std::ptrdiff_t
+ >
+ {
+ typedef boost::iterator_facade<
+ enum_iterator<EC>,
+ EC,
+ boost::random_access_traversal_tag,
+ EC,
+ std::ptrdiff_t
+ > base_t;
+ public:
+ typedef typename base_t::value_type value_type;
+ typedef typename base_t::difference_type difference_type;
+ typedef typename base_t::reference reference;
+
+ enum_iterator() : index_(0) {}
+ explicit enum_iterator(int x) : index_(x) {}
+
+ private:
+ void increment()
+ {
+ ++index_;
+ }
+
+ void decrement()
+ {
+ --index_;
+ }
+
+ void advance(difference_type offset)
+ {
+ index_ += offset;
+ }
+
+ difference_type distance_to(const enum_iterator& other) const
+ {
+ return other.index_ - index_;
+ }
+
+ bool equal(const enum_iterator& other) const
+ {
+ return index_ == other.index_;
+ }
+
+ reference dereference() const
+ {
+ return enums::val<EC>(index_);
+ }
+
+ friend class ::boost::iterator_core_access;
+ int index_;
+ };
+ } // namespace enums_detail
+ #endif
+ //! \c enum_range is a model of the \e RandomAccessRange Concept associated to the enumeration \c EC.
+
+
+ template<typename EC/* , typename Traits=enum_range_traits<EC> */ >
+ class enum_range
+ : public iterator_range< enums_detail::enum_iterator<EC/*, Traits*/> >
+ {
+ typedef enums_detail::enum_iterator<EC/*, Traits*/> iterator_t;
+ typedef iterator_range<iterator_t> base_t;
+ public:
+ //! builds a enum range
+ enum_range()
+ : base_t(iterator_t(0), iterator_t(enums::meta::size<EC>::value))
+ {
+ }
+
+ //! builds a enum sub-range
+ enum_range(EC first, EC last)
+ : base_t(iterator_t(enums::pos(first)),
+ iterator_t(enums::pos(last)+1))
+ {
+ }
+ };
+
+ //! function to generate an enum range.
+
+ //! \c make_range allows treating enums as a model of the \e RandomAccessRange Concept.
+
+ //! \pre \c EC is a model of the \e Enumeration Concept.
+
+ template<typename EC /*, typename Traits*/ >
+ enum_range<EC>
+ make_range()
+ {
+ return enum_range<EC/*,Traits*/>();
+ }
+
+ //! function to generate an enum sub-range.
+
+ //! \c make_range allows treating enums as a model of the \e RandomAccessRange Concept.
+ //! It should be noted that the first and last parameters denoted a closed range.
+ //! \pre \c EC is a model of the \e Enumeration Concept.
+ //! \param first first element of the range
+ //! \param last last element of the range
+ template<typename EC /*, typename Traits */ >
+ enum_range<EC>
+ make_range(EC first, EC last)
+ {
+ return enum_range<EC /*,Traits*/ >(first,last);
+ }
+
+ } // namespace enums
+} // namespace boost
+
+#endif // BOOST_ENUMS_CONTAINERS_ENUM_RANGE_HPP
Added: sandbox/enums/boost/enums/containers/enum_set.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/containers/enum_set.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -0,0 +1,437 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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)
+//
+// Based on the boost/array.hpp implementation
+//
+// See http://www.boost.org/libs/enums for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/*!
+ \file
+ \brief
+ The header \c <boost/enums/containers/enum_set.hpp> defines a class template \c enum_set<EC> for managing sets of enumeration and several
+ //! related functions for representing and manipulating sets of enums. We can say that
+ \c enum_set is the counterpart of \c std::bitset when the index are enums.
+ */
+
+#ifndef BOOST_ENUMS_CONTAINERS_ENUM_SET_HPP
+#define BOOST_ENUMS_CONTAINERS_ENUM_SET_HPP
+
+#include <boost/enums/ordinal/pos.hpp>
+#include <boost/enums/ordinal/size.hpp>
+#include <bitset>
+#include <stdexcept>
+#include <iosfwd>
+#include <string>
+#include <cstddef>
+#include <climits>
+#include <string>
+#include <boost/functional/hash.hpp>
+
+#include <boost/config.hpp>
+
+namespace boost {
+ namespace enums {
+
+ template<typename EC /*,
+ typename Traits=enum_subrange_traiter<EC>*/ >
+ class enum_set
+ {
+ public:
+ struct reference {
+ };
+ //! <b> Effects:</b> Constructs an object of class \c enum_set<>, initializing all
+ //! enumerations to zero.
+ BOOST_CONSTEXPR enum_set()
+ {
+ }
+ //~ BOOST_CONSTEXPR
+ // Need to be refactored to be a constexpr
+ //~ error: constexpr constructor does not have empty body
+ explicit enum_set(EC setting)
+ {
+ set(setting);
+ }
+
+ //! <b> Effects:</b> Constructs an object of class \c enum_set<>, initializing the
+ //! first \c M bit positions to the corresponding bit values in \c val.
+ //! \c M is the smaller of \c N and the number of bits in the value
+ //! representation of \c unsigned \c long \c long. If \c M<N, the remaining bit
+ //! positions are initialized to zero.
+ BOOST_CONSTEXPR explicit enum_set(unsigned long long val)
+ : bits(val)
+ {
+ }
+ //#if defined(__GNUC__) && (__GNUC__ < 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ < 4 ))
+ #if 1
+ #else
+
+ //! \pre <tt>pos <= str.size()</tt>.
+ //! \throws out_of_range if <tt>pos > str.size()</tt>.
+ //! <b> Effects:</b> Determines the effective length \c rlen of the initializing
+ //! string as the smaller of \c n and <tt>str.size()-pos</tt>.
+ //! The function then throws \c invalid_argument if any of the \c rlen
+ //! characters in \c str beginning at position pos is other than zero or one.
+ //! The function uses \c ch_traits::eq() to compare the character values.
+ //! Otherwise, the function constructs an object of class \c enum_set<EC>,
+ //! initializing the first \c M bit positions to values determined from the
+ //! corresponding characters in the string \c str. \c M is the smaller of \c N and
+ //! \c rlen.\n
+ //! An element of the constructed string has value zero if the
+ //! corresponding character in \c str, beginning at position \c pos, is \c 0 zero.
+ //! Otherwise, the element has the value 1. Character position \c pos+M-1
+ //! corresponds to bit position zero. Subsequent decreasing character
+ //! positions correspond to increasing bit positions.
+ //! If \c M<N, remaining bit positions are initialized to zero.
+ template<class charT, class ch_traits, class TAllocator>
+ explicit enum_set(const std::basic_string<charT,ch_traits,TAllocator>& str,
+ typename std::basic_string<charT,ch_traits,TAllocator>::size_type pos = 0,
+ typename std::basic_string<charT,ch_traits,TAllocator>::size_type n =
+ std::basic_string<charT,ch_traits,TAllocator>::npos,
+ charT zero = charT('0'), charT one = charT('1'))
+ : bits(str, pos, n, zero, one)
+ {}
+
+ //! <b> Effects:</b> Constructs an object of class enum_set<N> as if by enum_set(string(str)).
+ template <class charT>
+ explicit enum_set(const charT* str,
+ typename std::basic_string<charT>::size_type n = std::basic_string<charT>::npos,
+ charT zero = charT('0'), charT one = charT('1'))
+ : bits(str,n, zero, one)
+ {}
+ #endif
+
+ //! <b> Effects:</b> Clears each bit in \c *this for which the corresponding bit in
+ //! \c rhs is clear, and leaves all other bits unchanged.
+ //! \returns \c *this.
+ enum_set &operator&=(const enum_set &rhs)
+ {
+ bits &= rhs.bits;
+ return *this;
+ }
+
+ //! <b> Effects:</b> Sets each bit in \c *this for which the corresponding bit in
+ //! \c rhs is set, and leaves all other bits unchanged.
+ //! \returns \c *this.
+ enum_set &operator|=(const enum_set &rhs)
+ {
+ bits |= rhs.bits;
+ return *this;
+ }
+
+ //! <b> Effects:</b> Toggles each bit in \c *this for which the corresponding bit in
+ //! \c rhs is set, and leaves all other bits unchanged.
+ //! \returns \c *this.
+ enum_set &operator^=(const enum_set &rhs)
+ {
+ bits ^= rhs.bits;
+ return *this;
+ }
+
+ //! <b> Effects:</b> Replaces each bit at position \c I in \c *this with a value determined as follows:
+ //! - If \c I<pos, the new value is zero;
+ //! - If \c I>=pos, the new value is the previous value of the bit at position \c I-pos.
+ //! \returns \c *this.
+ enum_set &operator<<=(const enum_set &rhs)
+ {
+ bits <<= rhs.bits;
+ return *this;
+ }
+
+ //! <b> Effects:</b> Replaces each bit at position \c I in \c *this with a value determined as follows:
+ //! - If \c pos>=N-I, the new value is zero;
+ //! - If \c pos<N-I, the new value is the previous value of the bit at position \c I+pos.
+ //! \returns \c *this.
+
+ enum_set &operator>>=(const enum_set &rhs)
+ {
+ bits >>= rhs.bits;
+ return *this;
+ }
+
+ //! \returns A count of the number of bits set in \c *this.
+ std::size_t count() const
+ {
+ return bits.count();
+ }
+
+ //! \returns \c static_size.
+ BOOST_CONSTEXPR std::size_t size() const
+ {
+ return bits.size();
+ }
+
+ //! \pre \c pos shall be valid.
+ //! \throws nothing.
+ //! \returns \c true if the bit at position \c pos in \c *this has the value one,
+ //! otherwise \c false.
+ BOOST_CONSTEXPR bool operator[](EC testing) const
+ {
+ return bits.test(to_bit(testing));
+ }
+
+ //! \pre \c pos shall be valid.
+ //! \throws nothing.
+ //! \returns An object of type \c enum_set<EC>::reference such that
+ //! <tt>(*this)[pos] == this->test(pos)</tt>, and such that <tt>(*this)[pos] = val</tt> is
+ //! equivalent to <tt>this->set(pos, val)</tt>.
+ //! \note For the purpose of determining the presence of a data race,
+ //! any access or update through the resulting reference potentially
+ //! accesses or modifies, respectively, the entire underlying bitset.
+ reference operator[](std::size_t pos); // for b[i];
+
+ //! <b> Effects:</b> Sets all bits in \c *this.
+ //! \returns \c *this.
+
+ enum_set &set()
+ {
+ bits.set();
+ return *this;
+ }
+
+ //! \pre \c setting is valid
+ //! \throws out_of_range if \c pos does not correspond to a valid bit position.
+ //! <b> Effects:</b> Stores a new value in the bit at the position associated to \c setting in \c *this.
+ //! If \c value is nonzero, the stored value is one, otherwise it is zero.
+ //! \returns \c *this.
+ enum_set &set(EC setting, bool value = true)
+ {
+ bits.set(to_bit(setting), value);
+ return *this;
+ }
+
+ //! <b> Effects:</b> Resets all bits in \c *this.
+ //! \returns \c *this.
+ enum_set &reset()
+ {
+ bits.reset();
+ return *this;
+ }
+
+ //! \pre \c resetting is valid
+ //! \throws out_of_range if \c resetting does not correspond to a valid enum.
+ //! <b> Effects:</b> Resets the bit at the position associated to \c resetting in \c *this.
+ //! \returns \c *this.
+
+ enum_set &reset(EC resetting)
+ {
+ bits.reset(to_bit(resetting));
+ return *this;
+ }
+
+ //! <b> Effects:</b> Toggles all bits in \c *this.
+ //! \returns \c *this.
+ enum_set &flip()
+ {
+ bits.flip();
+ return *this;
+ }
+
+ //! \pre \c flipping is valid
+ //! \throws out_of_range if \c flipping does not correspond to a valid enum.
+ //! <b> Effects:</b> Toggles the bit at position associated to \c pos in \c *this.
+ //! \returns \c *this.
+ enum_set &flip(EC flipping)
+ {
+ bits.flip(to_bit(flipping));
+ return *this;
+ }
+
+ //! \c <tt>unsigned long</tt> conversion
+ //! \throws overflow_error if the integral value \c x corresponding to the
+ //! bits in \c *this cannot be represented as type <<tt>unsigned long</tt>.
+ //! \returns \c x.
+
+ unsigned long to_ulong() const
+ {
+ return bits.to_ulong();
+ }
+
+ //! \c <tt>unsigned long long</tt> conversion
+ //! \throws overflow_error if the integral value \c x corresponding to the
+ //! bits in \c *this cannot be represented as type <tt>unsigned long long</tt>.
+ //! \returns \c x.
+ unsigned long long to_ullong() const
+ {
+ return bits.to_ulong();
+ }
+#ifdef BOOST_ENUMS_DOXYGEN_INVOKED
+
+ //! <b> Effects:</b> Constructs a string object of the appropriate type and
+ //! initializes it to a string of length \c N characters. Each character is
+ //! determined by the value of its corresponding bit position in \c *this.
+ //! Character position \c N-1 corresponds to bit position zero.
+ //! Subsequent decreasing character positions correspond to increasing
+ //! bit positions. Bit value zero becomes the character zero, bit value
+ //! one becomes the character one.
+ //! \returns The created object.
+ template <class charT = char,
+ class traits = std::char_traits<charT>,
+ class Allocator = std::allocator<charT> >
+ std::basic_string<charT, traits, Allocator>
+ to_string(charT zero = charT('0'), charT one = charT('1')) const;
+#endif
+ //! <b> Effects:</b> Constructs an object x of class enum_set<EC> and initializes it with *this.
+ //! \returns \c x.flip().
+ enum_set operator~() const
+ {
+ return enum_set(*this).flip();
+ }
+
+ //! \pre \c testing is valid
+ //! \throws out_of_range if the associated position of \c testing does not correspond to a valid bit position.
+ //! \returns \c true if the bit at position \c pos in \c *this has the value one.
+ bool test(EC testing);
+
+ //! \returns <tt>count() == size()</tt>
+ bool all() const
+ {
+ return bits.all();
+ }
+
+ //! \returns <tt>count() != 0</tt>
+ bool any() const
+ {
+ return bits.any();
+ }
+
+ //! \returns <tt>count() == 0</tt>
+ bool none() const
+ {
+ return bits.none();
+ }
+
+ //! \returns <tt>enum_set<EC>(*this) <<= pos</tt>.
+ enum_set operator<<(std::size_t pos) const
+ {
+ enum_set r = *this;
+ r <<= pos;
+ return r;
+ }
+
+ //! \returns <tt>enum_set<EC>(*this) >>= pos</tt>.
+ enum_set operator>>(std::size_t pos) const
+ {
+ enum_set r = *this;
+ r >>= pos;
+ return r;
+ }
+
+ //! \returns A nonzero value if the value of each bit in \c *this equals the
+ //! value of the corresponding bit in \c rhs.
+ bool operator==(const enum_set& rhs) const;
+
+ //! \returns A nonzero value if <tt>!(*this == rhs)</tt>.
+ bool operator!=(const enum_set& rhs) const;
+ private:
+
+ static std::size_t to_bit(EC value)
+ {
+ return enums::pos(value);
+ }
+
+ std::bitset<enums::meta::size<EC>::value> bits;
+
+ public:
+
+ std::bitset<enums::meta::size<EC>::value> detail_bits() { return bits; }
+ };
+
+ // enum_set operators:
+
+ //! Intersection
+
+ //! \returns enum_set<EC>(lhs) &= rhs.
+ template <typename EC/*, typename Traits*/>
+ enum_set<EC/*,Traits*/> operator&(const enum_set<EC/*,Traits*/>& x, const enum_set<EC/*,Traits*/>& y)
+ {
+ enum_set<EC/*,Traits*/> r = x;
+ r &= y;
+ return r;
+ }
+
+ //! Union
+
+ //! \returns enum_set<EC>>(lhs) |= rhs.
+ template <typename EC/*, typename Traits*/ >
+ enum_set<EC/*,Traits*/> operator|(const enum_set<EC/*,Traits*/>& x, const enum_set<EC/*,Traits*/>& y)
+ {
+ enum_set<EC/*,Traits*/> r = x;
+ r |= y;
+ return r;
+ }
+
+ //! Exclusive union
+
+ //! \returns enum_set<EC>(lhs) ^= rhs.
+ template <typename EC/*, typename Traits*/ >
+ enum_set<EC/*,Traits*/> operator^(const enum_set<EC/*,Traits*/>& x, const enum_set<EC/*,Traits*/>& y)
+ {
+ enum_set<EC/*,Traits*/> r = x;
+ r ^= y;
+ return r;
+ }
+
+ //! A formatted input function.
+
+ //! \details <b> Effects:</b> Extracts up to \c N characters from is. Stores these characters
+ //! in a temporary object \c str of type <tt>basic_string<charT, traits></tt>, then
+ //! evaluates the expression <tt>x = enum_set<EC>(str)</tt>. Characters are extracted
+ //! and stored until any of the following occurs:
+ //! - \c N characters have been extracted and stored;
+ //! - end-of-file occurs on the input sequence;
+ //! - the next input character is neither \c is.widen('0') nor \c is.widen('1')
+ //! (in which case the input character is not extracted).\n
+ //! If no characters are stored in \c str, calls \c is.setstate(ios_base::failbit)
+ //! (which may throw <tt>ios_- base::failure</tt>).
+ //! \param is the input stream.
+ //! \param x the \c enum_set.
+ //! \returns \c is.
+
+ template <class charT, class ch_traits, typename EC/*, typename Traits*/ >
+ std::basic_istream<charT, ch_traits>&
+ operator>>(std::basic_istream<charT, ch_traits>& is, enum_set<EC/*,Traits*/>& x)
+ {
+ return is >> x.detail_bits();
+ }
+
+ //! A formatted output function.
+
+ //! \param os the output stream.
+ //! \param x the \c enum_set.
+ //! \returns <tt>os << x.template to_string<charT,traits,allocator<charT> >(
+ //! use_facet<ctype<charT> >(os.getloc()).widen('0'),
+ //! use_facet<ctype<charT> >(os.getloc()).widen('1'))</tt>
+ template <class charT, class ch_traits, typename EC/*, typename Traits*/ >
+ std::basic_ostream<charT, ch_traits>&
+ operator<<(std::basic_ostream<charT, ch_traits>& os, const enum_set<EC/*,Traits*/>& x)
+ {
+ return os << x.detail_bits();
+ }
+
+
+ } /* namespace enums */
+
+ //! hash template specialization
+
+ template <typename EC/*, typename Traits*/ >
+ struct hash<enums::enum_set<EC/*,Traits*/> >
+ : public std::unary_function<enums::enum_set<EC/*,Traits*/>, std::size_t>
+ {
+ //! \details the template specialization meets the requirements of class template \c hash.
+ std::size_t operator()(const enums::enum_set<EC/*,Traits*/>& bs) const
+ {
+ return hash<std::bitset<enums::meta::size<EC>::size> >(bs.detail_bits());
+ }
+ };
+
+} /* namespace boost */
+
+
+#endif /*BOOST_ENUMS_ENUM_SET_HPP*/
Deleted: sandbox/enums/boost/enums/default_value.hpp
==============================================================================
--- sandbox/enums/boost/enums/default_value.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,37 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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 BOOST_ENUMS_DEFAULT_VALUE_HPP
-#define BOOST_ENUMS_DEFAULT_VALUE_HPP
-
-#include <boost/enums/config.hpp>
-
-namespace boost {
- namespace enums {
-
- //! builds a enum class with the default value.
-
- //! \return the default value
- template <typename EC>
- inline EC default_value()
- {
-#ifdef BOOST_NO_SCOPED_ENUMS
- return EC::default_value();
-#else
- return EC();
-#endif
- }
-
- }
-}
-
-#endif
Deleted: sandbox/enums/boost/enums/emulation.hpp
==============================================================================
--- sandbox/enums/boost/enums/emulation.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,305 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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 BOOST_ENUMS_EMULATION_HPP
-#define BOOST_ENUMS_EMULATION_HPP
-
-#include <boost/enums/underlying_type.hpp>
-#include <boost/enums/enum_type.hpp>
-#include <boost/enums/scoping_type.hpp>
-#include <boost/enums/default_value.hpp>
-#include <boost/enums/enum_value.hpp>
-#include <boost/enums/underlying_value.hpp>
-#include <boost/conversion/convert_to.hpp>
-#include <boost/preprocessor/if.hpp>
-#include <boost/preprocessor/empty.hpp>
-#include <boost/enums/config.hpp>
-
-#ifndef BOOST_ENUMS_DOXYGEN_INVOKED
-
-#ifndef BOOST_NO_SCOPED_ENUMS
- #define BOOST_ENUMS_DETAIL_BINARY_OPERATOR(EC, UT, OP) \
- inline BOOST_CONSTEXPR bool operator OP(EC lhs, EC rhs) { \
- return (UT)(lhs) \
- OP \
- (UT)(rhs); \
- }
-
-#else // BOOST_NO_SCOPED_ENUMS
-
- #define BOOST_ENUMS_DETAIL_BINARY_OPERATOR(EC, UT, OP) \
- friend inline BOOST_CONSTEXPR bool operator OP(EC lhs, EC rhs) { \
- return lhs.enum_value() OP rhs.enum_value(); \
- } \
- friend inline BOOST_CONSTEXPR bool operator OP(type lhs, EC rhs) { \
- return lhs OP rhs.enum_value(); \
- } \
- friend inline BOOST_CONSTEXPR bool operator OP(EC lhs, type rhs) { \
- return lhs.enum_value() OP rhs; \
- }
-
-#endif // BOOST_NO_SCOPED_ENUMS
-
-#if !defined(BOOST_NO_SCOPED_ENUMS) && ! defined(BOOST_NO_SCOPED_ENUMS_COMPARE)
-
- #define BOOST_ENUMS_DETAIL_COMPARAISON_OPERATORS(EC, UT)
-
-#else // !defined(BOOST_NO_SCOPED_ENUMS) && ! defined(BOOST_NO_SCOPED_ENUMS_COMPARE)
-
- #define BOOST_ENUMS_DETAIL_COMPARAISON_OPERATORS(EC, UT) \
- BOOST_ENUMS_DETAIL_BINARY_OPERATOR(EC, UT, ==) \
- BOOST_ENUMS_DETAIL_BINARY_OPERATOR(EC, UT, !=) \
- BOOST_ENUMS_DETAIL_BINARY_OPERATOR(EC, UT, <) \
- BOOST_ENUMS_DETAIL_BINARY_OPERATOR(EC, UT, <=) \
- BOOST_ENUMS_DETAIL_BINARY_OPERATOR(EC, UT, >) \
- BOOST_ENUMS_DETAIL_BINARY_OPERATOR(EC, UT, >=)
-
-#endif // !defined(BOOST_NO_SCOPED_ENUMS) && ! defined(BOOST_NO_SCOPED_ENUMS_COMPARE)
-
- #define BOOST_ENUMS_DETAIL_SCOPING_TYPE_SPEC(EC) \
- namespace boost { \
- namespace enums { \
- template <> \
- struct scoping_type<enum_type<EC>::type> \
- { \
- typedef EC type; \
- }; \
- } \
- }
-
-#ifndef BOOST_NO_SCOPED_ENUMS
-
- #ifdef BOOST_NO_UNDERLYING_TYPE
-
- #define BOOST_ENUMS_DETAIL_UNDERLYING_TYPE_SPEC(EC, UT) \
- namespace boost { \
- namespace enums { \
- template <> \
- struct underlying_type<EC> \
- { \
- typedef UT type; \
- }; \
- } \
- }
-
- #else // BOOST_NO_UNDERLYING_TYPE
-
- #define BOOST_ENUMS_DETAIL_UNDERLYING_TYPE_SPEC(EC, UT)
-
- #endif // BOOST_NO_UNDERLYING_TYPE
-
-
- #define BOOST_ENUMS_DETAIL_FRIEND_CONVERSIONS(EC, UT) \
- inline EC convert_to(UT v \
- , boost::dummy::type_tag<EC> const& \
- ) \
- { \
- return EC(v); \
- } \
- inline EC convert_to(boost::enums::enum_type<EC>::type v \
- , boost::dummy::type_tag<EC> const& \
- ) \
- { \
- return v; \
- } \
- inline UT convert_to(EC v \
- , boost::dummy::type_tag<UT> const& \
- ) \
- { \
- return boost::enums::underlying_value(v); \
- }
-#else
-
-#define BOOST_ENUMS_DETAIL_CONSTRUCTORS(EC, UT) \
- EC() : val_(static_cast<underlying_type>(type())) { } \
- EC(type v) : val_(static_cast<underlying_type>(v)) { } \
- explicit EC(underlying_type v) : val_(v) { }
-
-
-#define BOOST_ENUMS_DETAIL_CONVERSIONS(EC, UT) \
- operator type() { return type(val_); }
-
-
-#define BOOST_ENUMS_DETAIL_END_1(EC, UT) \
- ; \
- typedef UT underlying_type; \
- private: \
- underlying_type val_; \
- public:
-
-
-
-#define BOOST_ENUMS_DETAIL_FRIEND_CONVERSIONS(EC, UT) \
- inline friend EC convert_to(UT v \
- , boost::dummy::type_tag<EC> const& \
- ) \
- { \
- return EC::convert_to(v); \
- } \
- inline friend EC convert_to(boost::enums::enum_type<EC>::type v \
- , boost::dummy::type_tag<EC> const& \
- ) \
- { \
- return EC::convert_to(v); \
- } \
- inline friend UT convert_to(EC v \
- , boost::dummy::type_tag<UT> const& \
- ) \
- { \
- return boost::enums::underlying_value(v); \
- } \
- inline friend boost::enums::enum_type<EC>::type convert_to(EC v \
- , boost::dummy::type_tag<boost::enums::enum_type<EC>::type> const& \
- ) \
- { \
- return boost::enums::enum_value(v); \
- }
-
-
-#define BOOST_ENUMS_DETAIL_END_2(EC, UT) \
- EC& operator =(type rhs) { \
- val_=static_cast<underlying_type>(rhs); \
- return *this; \
- } \
- static EC default_value() \
- { \
- EC res; \
- res.val_=static_cast<underlying_type>(EC::type()); \
- return res; \
- } \
- static EC convert_to(underlying_type v) \
- { \
- EC res; \
- res.val_=v; \
- return res; \
- } \
- static EC convert_to(type v) \
- { \
- EC res; \
- res.val_=static_cast<underlying_type>(v); \
- return res; \
- } \
- type enum_value() const \
- { \
- return type(val_); \
- } \
- underlying_type underlying_value() const \
- { \
- return val_; \
- } \
- BOOST_ENUMS_DETAIL_FRIEND_CONVERSIONS(EC, UT)
-
-
-#endif
-#endif
-
-#ifndef BOOST_NO_SCOPED_ENUMS
-
- #define BOOST_ENUM_CLASS_START(EC, UT) \
- enum class EC : UT
-
- #define BOOST_ENUM_TYPE_START(EC, UT) \
- enum EC : UT
-
- #define BOOST_ENUM_CLASS_END(EC, UT) \
- ; \
- BOOST_ENUMS_DETAIL_FRIEND_CONVERSIONS(EC, UT) \
- BOOST_ENUMS_DETAIL_COMPARAISON_OPERATORS(EC, UT)
-
- #define BOOST_ENUM_TYPE_END(EC, UT) \
- ; \
- BOOST_ENUMS_DETAIL_FRIEND_CONVERSIONS(EC, UT) \
- BOOST_ENUMS_DETAIL_COMPARAISON_OPERATORS(EC, UT)
-
- #define BOOST_ENUM_CLASS_NO_CONS_END(EC, UT) \
- ; \
- BOOST_ENUMS_DETAIL_FRIEND_CONVERSIONS(EC, UT) \
- BOOST_ENUMS_DETAIL_COMPARAISON_OPERATORS(EC, UT)
-
- #define BOOST_ENUM_TYPE_NO_CONS_END(EC, UT) \
- ; \
- BOOST_ENUMS_DETAIL_FRIEND_CONVERSIONS(EC, UT) \
- BOOST_ENUMS_DETAIL_COMPARAISON_OPERATORS(EC, UT)
-
- #define BOOST_ENUM_CLASS_CONS_END(EC, UT) \
- ; \
- BOOST_ENUMS_DETAIL_FRIEND_CONVERSIONS(EC, UT) \
- BOOST_ENUMS_DETAIL_COMPARAISON_OPERATORS(EC, UT)
-
- #define BOOST_ENUM_TYPE_CONS_END(EC, UT) \
- ; \
- BOOST_ENUMS_DETAIL_FRIEND_CONVERSIONS(EC, UT) \
- BOOST_ENUMS_DETAIL_COMPARAISON_OPERATORS(EC, UT)
-
- #define BOOST_ENUMS_SPECIALIZATIONS(EC, UT) \
- BOOST_ENUMS_DETAIL_UNDERLYING_TYPE_SPEC(EC, UT)
-
-#else // BOOST_NO_SCOPED_ENUMS
-
- #define BOOST_ENUM_CLASS_START(EC, UT) \
- class EC \
- { \
- public: \
- enum type
-
- #define BOOST_ENUM_TYPE_START(EC, UT) \
- class EC \
- { \
- public: \
- enum type
-
-
- #define BOOST_ENUM_CLASS_END(EC, UT) \
- BOOST_ENUMS_DETAIL_END_1(EC, UT) \
- BOOST_ENUMS_DETAIL_END_2(EC, UT) \
- BOOST_ENUMS_DETAIL_COMPARAISON_OPERATORS(EC, UT) \
- };
-
-
- #define BOOST_ENUM_TYPE_END(EC, UT) \
- BOOST_ENUMS_DETAIL_END_1(EC, UT) \
- BOOST_ENUMS_DETAIL_CONVERSIONS(EC, UT) \
- BOOST_ENUMS_DETAIL_END_2(EC, UT) \
- };
-
- #define BOOST_ENUM_CLASS_NO_CONS_END(EC, UT) \
- BOOST_ENUMS_DETAIL_END_1(EC, UT) \
- BOOST_ENUMS_DETAIL_END_2(EC, UT) \
- BOOST_ENUMS_DETAIL_COMPARAISON_OPERATORS(EC, UT) \
- };
-
- #define BOOST_ENUM_TYPE_NO_CONS_END(EC, UT) \
- BOOST_ENUMS_DETAIL_END_1(EC, UT) \
- BOOST_ENUMS_DETAIL_CONVERSIONS(EC, UT) \
- BOOST_ENUMS_DETAIL_END_2(EC, UT) \
- };
-
- #define BOOST_ENUM_CLASS_CONS_END(EC, UT) \
- BOOST_ENUMS_DETAIL_END_1(EC, UT) \
- BOOST_ENUMS_DETAIL_CONSTRUCTORS(EC, UT) \
- BOOST_ENUMS_DETAIL_END_2(EC, UT) \
- BOOST_ENUMS_DETAIL_COMPARAISON_OPERATORS(EC, UT) \
- };
-
- #define BOOST_ENUM_TYPE_CONS_END(EC, UT) \
- BOOST_ENUMS_DETAIL_END_1(EC, UT) \
- BOOST_ENUMS_DETAIL_CONSTRUCTORS(EC, UT) \
- BOOST_ENUMS_DETAIL_CONVERSIONS(EC, UT) \
- BOOST_ENUMS_DETAIL_END_2(EC, UT) \
- };
-
-#define BOOST_ENUMS_SPECIALIZATIONS(EC, UT) \
- BOOST_ENUMS_DETAIL_SCOPING_TYPE_SPEC(EC)
-
-
-#endif // BOOST_NO_SCOPED_ENUMS
-#endif
Deleted: sandbox/enums/boost/enums/enum_array.hpp
==============================================================================
--- sandbox/enums/boost/enums/enum_array.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,488 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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)
-//
-// Based on the boost/array.hpp implementation
-//
-// See http://www.boost.org/libs/enums for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-/*!
-\file
-\brief
-The header \c <boost/enums/enum_array.hpp> defines a class template for storing
-sequences of objects fixed by the size of the enumeration.
-We can say that
-\c enum_array is the counterpart of \c std::array when the index are enums.
-*/
-
-#ifndef BOOST_ENUMS_ENUM_ARRAY_HPP
-#define BOOST_ENUMS_ENUM_ARRAY_HPP
-
-#include <boost/detail/workaround.hpp>
-
-#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
-# pragma warning(push)
-# pragma warning(disable:4996) // 'std::equal': Function call with parameters that may be unsafe
-# pragma warning(disable:4510) // boost::enums::enum_array<T,EC>' : default constructor could not be generated
-# pragma warning(disable:4610) // warning C4610: class 'boost::enums::enum_array<T,EC>' can never be instantiated - user defined constructor required
-#endif
-
-#include <cstddef>
-#include <stdexcept>
-#include <boost/assert.hpp>
-#include <boost/swap.hpp>
-
-// Handles broken standard libraries better than <iterator>
-#include <boost/detail/iterator.hpp>
-#include <boost/throw_exception.hpp>
-#include <algorithm>
-
-#include <boost/enums/size.hpp>
-#include <boost/enums/pos.hpp>
-#include <boost/type_traits/integral_constant.hpp>
-
-// FIXES for broken compilers + CONSTEXPR
-#include <boost/config.hpp>
-
-namespace boost
-{
- namespace enums
- {
-
- /*!
- An \c enum_array supports random access iterators. An instance of \c enum_array<T, EC>
- stores as many elements of type \c T as enum literals are on the enum class \c EC,
- so that <tt>size() == meta::size<EC>::value</tt> is an invariant.
-
- The elements of an \c enum_array are stored contiguously, meaning that if \c a is an
- \c enum_array<T, EC>, then it obeys the identity
-
- \code
- &a[n] == &a[0] + n for all 0 <= n < meta::size<EC>::value.
- \endcode
-
- An \c enum_array is an aggregate that can (????) be initialized with the syntax
-
- \code
- enum_array<T, EC> a = { initializer-list };
- \endcode
-
- where \e initializer-list is a comma separated list of up to \c meta::size<EC>::value
- elements whose types are convertible to \c T.
-
- An \c enum_array satisfies all of the requirements of a container and of a
- reversible container, except that a default constructed array object is not
- empty and that swap does not have constant complexity. An \c enum_array satisfies
- some of the requirements of a sequence container. Descriptions are provided
- here only for operations on enum_array that are not described in one of these
- tables and for operations where there is additional semantic information.
-
- The conditions for an aggregate are met. Class enum_array relies on
- the implicitly-declared special member functions to conform to the
- container requirements
-
-
-
- \note The member variable elems is shown for exposition only, to emphasize
- that enum_array is a class aggregate. The name elems is not part of
- enum_array's interface
-
- \param T array's element type
- \param EC array's index enumeration class
- */
-
- template<class T, typename EC>
- class enum_array {
- public:
- //! // exposition only
- T elems[meta::size<EC>::value]; // fixed-size array of elements of type T
-
- public:
- // type definitions
- typedef T value_type;
- typedef T* iterator;
- typedef const T* const_iterator;
- typedef T& reference;
- typedef const T& const_reference;
- typedef value_type* pointer;
- typedef const value_type* const_pointer;
- typedef EC key_type;
- typedef std::size_t size_type;
- typedef std::ptrdiff_t difference_type;
- static const std::size_t static_size = meta::size<EC>::value;
- //enum_array() {}
-
- // iterator support
- //! \returns iterator for the first element
- //! \throws Nothing
- iterator begin() { return elems; }
-
- //! \returns const iterator for the first element
- //! \throws Nothing
- const_iterator begin() const { return elems; }
- const_iterator cbegin() const { return elems; }
-
- //! \returns iterator for position after the last element
- //! \throws Nothing
- iterator end() { return elems+static_size; }
-
- //! \returns const iterator for position after the last element
- //! \throws Nothing
- const_iterator end() const { return elems+static_size; }
- const_iterator cend() const { return elems+static_size; }
-
- // reverse iterator support
-#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS)
- typedef std::reverse_iterator<iterator> reverse_iterator;
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
-#elif defined(_MSC_VER) && (_MSC_VER == 1300) && defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB == 310)
- // workaround for broken reverse_iterator in VC7
- typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, iterator,
- reference, iterator, reference> > reverse_iterator;
- typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, const_iterator,
- const_reference, iterator, reference> > const_reverse_iterator;
-#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC)
- typedef std::reverse_iterator<iterator, std::random_access_iterator_tag,
- value_type, reference, iterator, difference_type> reverse_iterator;
- typedef std::reverse_iterator<const_iterator, std::random_access_iterator_tag,
- value_type, const_reference, const_iterator, difference_type> const_reverse_iterator;
-#else
- // workaround for broken reverse_iterator implementations
- typedef std::reverse_iterator<iterator,T> reverse_iterator;
- typedef std::reverse_iterator<const_iterator,T> const_reverse_iterator;
-#endif
-
- //! \returns reverse iterator for the first element of reverse iteration
- reverse_iterator rbegin() {
- return reverse_iterator(end());
- }
- const_reverse_iterator rbegin() const {
- return const_reverse_iterator(end());
- }
- const_reverse_iterator crbegin() const {
- return const_reverse_iterator(end());
- }
-
- //! \returns reverse iterator for position after the last element in reverse iteration
- reverse_iterator rend() {
- return reverse_iterator(begin());
- }
- const_reverse_iterator rend() const {
- return const_reverse_iterator(begin());
- }
- const_reverse_iterator crend() const {
- return const_reverse_iterator(begin());
- }
-
- // operator[]
- //! Requires: k'pos < static_size
- //! \returns reference to the element with key k
- //! \throws Nothing.
- reference operator[](key_type k)
- {
- size_type i = pos(k);
- BOOST_ASSERT( i < static_size && "out of range" );
- return elems[i];
- }
-
- //! Requires: k'pos < static_size
- //! \returns constant reference to the element with key k
- //! \throws Nothing.
- const_reference operator[](key_type k) const
- {
- size_type i = pos(k);
- BOOST_ASSERT( i < static_size && "out of range" );
- return elems[i];
- }
-
- // at() with range check
- //! \returns element with key k
- //! \throws std::range_error if i >= static_size
- reference at(key_type k)
- {
- size_type i = rangecheck(k);
- return elems[i];
- }
- const_reference at(key_type k) const
- {
- size_type i = rangecheck(k);
- return elems[i];
- }
-
- // front() and back()
- //! \returns reference to the first element
- //! \throws Nothing
- reference front()
- {
- return elems[0];
- }
-
- //! \returns const reference to the first element
- //! \throws Nothing
- const_reference front() const
- {
- return elems[0];
- }
-
- //! \returns reference to the last element
- //! \throws Nothing
- reference back()
- {
- return elems[static_size-1];
- }
-
- //! \returns const reference to the last element
- //! \throws Nothing
- const_reference back() const
- {
- return elems[static_size-1];
- }
-
- // size is constant
- //! \returns linear in meta::size<EC>::value.
- BOOST_CONSTEXPR size_type size()
- {
- return static_size;
- }
- //! \returns false
- //! \throws Nothing
- static bool empty()
- {
- return false;
- }
-
- //! \returns linear in meta::size<EC>::value.
- BOOST_CONSTEXPR size_type max_size()
- {
- return static_size;
- }
-
-
- /*! Effects: swap_ranges(begin(), end(), y.begin())
- \throws Nothing unless one of the element-wise swap calls throws an exception.
- Note: Unlike the swap function for other containers, enum_array::swap
- takes linear time, may exit via an exception, and does not cause
- iterators to become associated with the other container.
- */
- void swap (enum_array<T,EC>& y)
- {
- for (size_type i = 0; i < static_size; ++i)
- boost::swap(elems[i],y.elems[i]);
- }
-
- // direct access to data (read-only)
-
- //! \returns elems.
- const T* data() const {
- return elems;
- }
- //! \returns elems.
- T* data() {
- return elems;
- }
-
- // use enum_array as C array (direct read/write access to data)
- T* c_array() {
- return elems;
- }
-
- // assignment with type conversion
- template <typename T2>
- enum_array<T,EC>& operator= (const enum_array<T2,EC>& rhs) {
- std::copy(rhs.begin(),rhs.end(), begin());
- return *this;
- }
-
- // A synonym for fill
- // assign one value to all elements
- //! Effects: std::fill_n(begin(), static_size, value)
- void assign (const T& value) {
- fill ( value );
- }
-
- //! Effects: fill_n(begin(), static_size, u)
- void fill (const T& value)
- {
- std::fill_n(begin(),size(),value);
- }
-
- // check range (may be private because it is static)
- static size_type rangecheck (key_type k) {
- size_type i = enums::pos(k);
- if (i >= static_size) {
- std::out_of_range e("array<>: index out of range");
- boost::throw_exception(e);
- }
- return i;
- }
-
- };
-
-
-
- // comparisons
- //! \returns std::equal(x.begin(), x.end(), y.begin())
- template<class T, typename EC>
- bool operator== (const enum_array<T,EC>& x, const enum_array<T,EC>& y)
- {
- return std::equal(x.begin(), x.end(), y.begin());
- }
-
- //! \returns std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end())
- template<class T, typename EC>
- bool operator< (const enum_array<T,EC>& x, const enum_array<T,EC>& y)
- {
- return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end());
- }
-
- //! \returns !(x == y)
- template<class T, typename EC>
- bool operator!= (const enum_array<T,EC>& x, const enum_array<T,EC>& y)
- {
- return !(x==y);
- }
-
- //! \returns y < x
- template<class T, typename EC>
- bool operator> (const enum_array<T,EC>& x, const enum_array<T,EC>& y)
- {
- return y<x;
- }
- //! \returns !(y<x)
- template<class T, typename EC>
- bool operator<= (const enum_array<T,EC>& x, const enum_array<T,EC>& y)
- {
- return !(y<x);
- }
- //! \returns !(x<y)
- template<class T, typename EC>
- bool operator>= (const enum_array<T,EC>& x, const enum_array<T,EC>& y)
- {
- return !(x<y);
- }
-
- //! enum_array's swap
-
- //! <b>Effects:</b> As
- //! \code
- //! x.swap(y);
- //! \endcode
- //! <b>Complexity:</b> linear in \c meta::size<EC>::value.
-
- template<class T, typename EC>
- inline void swap (enum_array<T,EC>& x, enum_array<T,EC>& y)
- {
- x.swap(y);
- }
-
-#if defined(__SUNPRO_CC)
-// Trac ticket #4757; the Sun Solaris compiler can't handle
-// syntax like 'T(&get_c_array(boost::array<T,static_size>& arg))[static_size]'
-//
-// We can't just use this for all compilers, because the
-// borland compilers can't handle this form.
- namespace detail {
- template <typename T, typename EC> struct c_array
- {
- typedef T type[meta::size];
- };
- }
-
- // Specific for boost::enums::enum_array: simply returns its elems data member.
- template <typename T, typename EC>
- typename detail::c_array<T,static_size>::type& get_c_array(enum_array<T,EC>& arg)
- {
- return arg.elems;
- }
-
- // Specific for boost::enums::enum_array: simply returns its elems data member.
- template <typename T, typename EC>
- typename const detail::c_array<T,static_size>::type& get_c_array(const enum_array<T,EC>& arg)
- {
- return arg.elems;
- }
-#else
- template <typename T, typename EC>
- T(&get_c_array(enum_array<T,EC>& arg))[meta::size<EC>::value]
- {
- //! c_array conversion.
- return arg.elems;
- }
-
- template <typename T, typename EC>
- const T(&get_c_array(const enum_array<T,EC>& arg))[meta::size<EC>::value]
- {
- //! c_array const conversion.
- return arg.elems;
- }
-#endif
-
-#if 0
-
- template <class T, typename EC>
- class tuple_size<enum_array<T, EC> >
- : public integral_constant<size_t, meta::size<EC>::value>
- {};
-
- template <class T, typename EC>
- class tuple_size<const enum_array<T, EC> >
- : public integral_constant<size_t, meta::size<EC>::value>
- {};
-
- template <class T, typename EC, enum_type<EC>::type K>
- class tuple_element<enum_array<T, EC> >
- {
- public:
- typedef T type;
- };
-
- template <class T, typename EC, enum_type<EC>::type K>
- class tuple_element<const enum_array<T, EC> >
- {
- public:
- typedef const T type;
- };
-
- template <class T, typename EC, enum_type<EC>::type K>
- inline
- T&
- get(enum_array<T, EC>& a)
- {
- return a[K];
- }
-
- template <class T, typename EC, enum_type<EC>::type K>
- inline
- const T&
- get(const enum_array<T, EC>& a)
- {
- return a[K];
- }
-
- #ifndef BOOST_NO_RVALUE_REFERENCES
-
- template <class T, typename EC, enum_type<EC>::type K>
- T&&
- get(array<T, meta::size<EC>::value>&& a)
- {
- return boost::move(a[K]);
- }
-
- #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#endif
-
-} /* namespace enums */
-} /* namespace boost */
-
-
-#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
-# pragma warning(pop)
-#endif
-
-#endif /*BOOST_ENUMS_ENUM_ARRAY_HPP*/
Deleted: sandbox/enums/boost/enums/enum_class_cons.hpp
==============================================================================
--- sandbox/enums/boost/enums/enum_class_cons.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,231 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-/*!
- \file
- \brief
- The header \c <boost/enums/enum_class_cons.hpp> defines the declaration of enum_class_cons<> template class.
- */
-
-#ifndef BOOST_ENUMS_ENUM_TYPE_CONS_HPP
-#define BOOST_ENUMS_ENUM_TYPE_CONS_HPP
-
-#include <boost/config.hpp>
-
-namespace boost
-{
- namespace enums
- {
- //! scoped enum class with constructors
-
- //! param @c ScopedEnum : Struct scoping the enum.\n
- //! param @c UT : the underlaying storage type.\n
- //! pre @c ScopedEnum must have a nested C++98 enum @c type.\n
-
- template <typename ScopedEnum, typename UT=int>
- class enum_class_cons : public ScopedEnum
- {
- public:
- //! c++98 enum type
- typedef typename ScopedEnum::type type;
- //! underlying type
- typedef UT underlying_type;
- private:
- underlying_type val_;
- public:
- //! default constructor
- enum_class_cons()
- : val_(static_cast<underlying_type>(type()))
- {
- }
- //! explicit constructor from underlying type
- explicit enum_class_cons(underlying_type v)
- : val_(v)
- {
- }
- //! constructor from enum type
- enum_class_cons(type v)
- : val_(static_cast<underlying_type>(v))
- {
- }
- //! assignment
- enum_class_cons& operator=(enum_class_cons rhs)
- {
- val_=rhs.val_;
- return *this;
- }
- //! assignment from enum literals
- enum_class_cons& operator=(type rhs)
- {
- val_=static_cast<underlying_type>(rhs);
- return *this;
- }
- //! workaround when there are no constructors
- static enum_class_cons default_value()
- {
- enum_class_cons res;
- res.val_=static_cast<underlying_type>(type());
- return res;
- }
-
- static enum_class_cons convert_to(underlying_type v)
- {
- enum_class_cons res;
- res.val_=v;
- return res;
-
- }
- static enum_class_cons convert_to(type v)
- {
- enum_class_cons res;
- res.val_=static_cast<underlying_type>(v);
- return res;
- }
- //! explicit conversion function to enum type
- type enum_value() const
- {
- return type(val_);
- }
- //! explicit conversion function to underlying_type
- underlying_type underlying_value() const
- {
- return val_;
- }
-
- //! equal operator
- friend bool operator==(enum_class_cons lhs, enum_class_cons rhs)
- {
- return lhs.val_ == rhs.val_;
- }
- //! equal operator
- friend bool operator==(type lhs, enum_class_cons rhs)
- {
- return lhs == rhs.val_;
- }
- //! equal operator
- friend bool operator==(enum_class_cons lhs, type rhs)
- {
- return lhs.val_ == rhs;
- }
- //! not_equal operator
- friend bool operator!=(enum_class_cons lhs, enum_class_cons rhs)
- {
- return lhs.val_ != rhs.val_;
- }
- //! not_equal operator
- friend bool operator!=(type lhs, enum_class_cons rhs)
- {
- return lhs != rhs.val_;
- }
- //! not_equal operator
- friend bool operator!=(enum_class_cons lhs, type rhs)
- {
- return lhs.val_ != rhs;
- }
- //! less_equal operator
- friend bool operator<=(enum_class_cons lhs, enum_class_cons rhs)
- {
- return lhs.val_ <= rhs.val_;
- }
- //! less_equal operator
- friend bool operator<=(type lhs, enum_class_cons rhs)
- {
- return lhs <= rhs.val_;
- }
- //! less_equal operator
- friend bool operator<=(enum_class_cons lhs, type rhs)
- {
- return lhs.val_ <= rhs;
- }
- //! less operator
- friend bool operator<(enum_class_cons lhs, enum_class_cons rhs)
- {
- return lhs.val_ < rhs.val_;
- }
- //! less operator
- friend bool operator<(type lhs, enum_class_cons rhs)
- {
- return lhs < rhs.val_;
- }
- //! less operator
- friend bool operator<(enum_class_cons lhs, type rhs)
- {
- return lhs.val_ < rhs;
- }
- //! greater_equal operator
- friend bool operator>=(enum_class_cons lhs, enum_class_cons rhs)
- {
- return lhs.val_ >= rhs.val_;
- }
- //! greater_equal operator
- friend bool operator>=(type lhs, enum_class_cons rhs)
- {
- return lhs >= rhs.val_;
- }
- //! greater_equal operator
- friend bool operator>=(enum_class_cons lhs, type rhs)
- {
- return lhs.val_ >= rhs;
- }
- //! greater operator
- friend bool operator>(enum_class_cons lhs, enum_class_cons rhs)
- {
- return lhs.val_ > rhs.val_;
- }
- //! greater operator
- friend bool operator>(type lhs, enum_class_cons rhs)
- {
- return lhs > rhs.val_;
- }
- //! greater operator
- friend bool operator>(enum_class_cons lhs, type rhs)
- {
- return lhs.val_ > rhs;
- }
-#if 0
- //! conversions from underlying_type to enum_type_cons following the Boost.Conversion protocol
- friend enum_class_cons convert_to(underlying_type v,
- boost::dummy::type_tag<enum_class_cons> const&)
- {
- enum_class_cons res;
- res.val_=v;
- return res;
-
- }
-
- //! friend conversions from type to enum_type_cons following the Boost.Conversion protocol
- friend enum_class_cons convert_to(type v,
- boost::dummy::type_tag<enum_class_cons> const&)
- {
- enum_class_cons res;
- res.val_=static_cast<underlying_type>(v);
- return res;
- }
-#endif
- //! conversions from enum_type_cons to underlying_type following the Boost.Conversion protocol
- friend underlying_type convert_to(enum_class_cons v,
- boost::dummy::type_tag<underlying_type> const&)
- {
- return boost::enums::underlying_value(v);
- }
-
- //! conversions from enum_type_cons to type following the Boost.Conversion protocol
- friend type convert_to(enum_class_cons v,
- boost::dummy::type_tag<type> const&)
- {
- return boost::enums::enum_value(v);
- }
- };
- }
-}
-
-#endif // BOOST_ENUMS_ENUM_TYPE_MIXIN_HPP
Deleted: sandbox/enums/boost/enums/enum_class_macro.hpp
==============================================================================
--- sandbox/enums/boost/enums/enum_class_macro.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,124 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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 BOOST_OPAQUE_ENUM_CLASS_MACRO_HPP
-#define BOOST_OPAQUE_ENUM_CLASS_MACRO_HPP
-
-#include <boost/enums/underlying_type.hpp>
-#include <boost/enums/enum_type.hpp>
-#include <boost/enums/default_value.hpp>
-#include <boost/enums/enum_value.hpp>
-#include <boost/conversion/convert_to.hpp>
-#include <boost/config.hpp>
-#include <boost/preprocessor/join.hpp>
-#include <boost/preprocessor/if.hpp>
-#include <boost/preprocessor/greater.hpp>
-#include <boost/preprocessor/empty.hpp>
-#include <boost/preprocessor/seq/enum.hpp>
-#include <boost/preprocessor/seq/elem.hpp>
-
-#define BOOST_OPAQUE_DETAIL_PAIR_TO_LITERAL(R, DATA, OPTPAIR) \
- BOOST_PP_JOIN(BOOST_PP_SEQ_ELEM(PAIR,0),DATA) \
- BOOST_PP_IF(BOOST_PP_GREATER(BOOST_PP_SE_SIZE(PAIR),1), \
- = BOOST_PP_SEQ_ELEM(PAIR,1),BOOST_PP_EMPTY)
-
-#define BOOST_OPAQUE_DETAIL_OPTPAIR_TO_NAME(EC, OPTPAIR) \
- EC::BOOST_PP_SEQ_ELEM(PAIR,0)
-
-#define BOOST_OPAQUE_DETAIL_OPTPAIR_TO_INTERNAL_NAME(OPTPAIR) \
- EC::BOOST_PP_JOIN(BOOST_PP_SEQ_ELEM(PAIR,0),_)
-
-#define BOOST_OPAQUE_DETAIL_CONST_DECLARATION(R, EC, OPTPAIR) \
- const EC BOOST_OPAQUE_DETAIL_OPTPAIR_TO_NAME(EC, OPTPAIR) \
-
-
-#define BOOST_OPAQUE_DETAIL_CONST_DEFINITION(R, EC, OPTPAIR) \
- const EC BOOST_OPAQUE_DETAIL_OPTPAIR_TO_NAME(EC, OPTPAIR) \
- = EC::convert_to( \
- BOOST_OPAQUE_DETAIL_OPTPAIR_TO_INTERNAL_NAME(EC, OPTPAIR) \
- ;
-
-
-#ifndef BOOST_NO_SCOPED_ENUMS
-
-#define BOOST_ENUM_CLASS(EC, UT, SEQ) \
- enum class EC : UT { \
- BOOST_PP_SEQ_ENUM( \
- BOOST_PP_SEQ_FOR_EACH( \
- BOOST_OPAQUE_DETAIL_PAIR_TO_LITERAL, \
- BOOST_PP_EMPTY, \
- SEQ \
- ) \
- ) \
- };
-
-#else // BOOST_NO_SCOPED_ENUMS
-
-#define BOOST_ENUM_CLASS_CONSTRUCTORS(EC, UT) \
- EC() : val_() { } \
- EC(UT v) : val_(v) { }
-
-#define BOOST_ENUM_CLASS_EXT(EC, UT, SEQ, CONS) \
- class EC \
- { \
- public: \
- enum type { \
- BOOST_PP_SEQ_ENUM( \
- BOOST_PP_SEQ_FOR_EACH( \
- BOOST_OPAQUE_DETAIL_PAIR_TO_LITERAL, \
- BOOST_PP_EMPTY, \
- SEQ \
- ) \
- ) \
- }; \
- typedef UT underlying_type; \
- private: \
- underlying_type val_; \
- public: \
- BOOST_PP_SEQ_FOR_EACH( \
- BOOST_OPAQUE_DETAIL_CONST_DECLARATION, \
- EC, \
- SEQ \
- ) \
- BOOST_PP_IF(CONS, \
- BOOST_ENUM_CLASS_CONSTRUCTORS(EC, UT), \
- BOOST_PP_EMPTY \
- ) \
- static EC default_value() \
- { \
- EC res; \
- res.val_=EnumClass::type(); \
- return res; \
- } \
- static EC convert_to(underlying_type v) \
- { \
- EC res; \
- res.val_=type(v); \
- return res; \
- } \
- type get() const \
- { \
- return type(val_); \
- } \
- }; \
- BOOST_PP_SEQ_FOR_EACH( \
- BOOST_OPAQUE_DETAIL_CONST_DEFINITION, \
- EC, \
- SEQ \
- ) \
-
-
-#define BOOST_ENUM_CLASS(EC, UT, SEQ) \
- BOOST_ENUM_CLASS_EXT(EC, UT, SEQ, defined(BOOST_ENUMS_NO_CONSTRUCTORS))
-
-#endif // BOOST_NO_SCOPED_ENUMS
-#endif
Deleted: sandbox/enums/boost/enums/enum_class_no_cons.hpp
==============================================================================
--- sandbox/enums/boost/enums/enum_class_no_cons.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,219 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-/*!
- \file
- \brief
- The header \c <boost/enums/enum_class_no_cons.hpp> defines the declaration of enum_class_no_cons<> template class.
- */
-
-#ifndef BOOST_ENUMS_ENUM_TYPE_NO_CONS_HPP
-#define BOOST_ENUMS_ENUM_TYPE_NO_CONS_HPP
-
-#include <boost/config.hpp>
-
-namespace boost
-{
- namespace enums
- {
- //! scoped enum class without constructors
-
- //! param @c ScopedEnum : Struct scoping the enum.\n
- //! param @c UT : the underlaying storage type.\n
- //! pre @c ScopedEnum must have a nested C++98 enum @c type.\n
- template <typename ScopedEnum, typename UT=int>
- class enum_class_no_cons : public ScopedEnum
- {
- public:
- //! c++98 enum type
- typedef typename ScopedEnum::type type;
- //! underlying type
- typedef UT underlying_type;
- private:
- underlying_type val_;
- public:
- //! assignment
- enum_class_no_cons& operator=(enum_class_no_cons rhs)
- {
- val_=rhs.val_;
- return *this;
- }
-
- //! assignment from enum literals
- enum_class_no_cons& operator=(type rhs)
- {
- val_=static_cast<underlying_type>(rhs);
- return *this;
- }
-
- //! workaround when there are no constructors
- static enum_class_no_cons default_value()
- {
- enum_class_no_cons res;
- res.val_=static_cast<underlying_type>(type());
- return res;
- }
-
- static enum_class_no_cons convert_to(underlying_type v)
- {
- enum_class_no_cons res;
- res.val_=v;
- return res;
-
- }
-
- static enum_class_no_cons convert_to(type v)
- {
- enum_class_no_cons res;
- res.val_=static_cast<underlying_type>(v);
- return res;
- }
-
- //! explicit conversion function to enum type
- type enum_value() const
- {
- return type(val_);
- }
-
- //! explicit conversion function to underlying_type
- underlying_type underlying_value() const
- {
- return val_;
- }
-
- //! equal operator
- friend bool operator==(enum_class_no_cons lhs, enum_class_no_cons rhs)
- {
- return lhs.val_ == rhs.val_;
- }
- //! equal operator
- friend bool operator==(type lhs, enum_class_no_cons rhs)
- {
- return lhs == rhs.val_;
- }
- //! equal operator
- friend bool operator==(enum_class_no_cons lhs, type rhs)
- {
- return lhs.val_ == rhs;
- }
- //! not_equal operator
- friend bool operator!=(enum_class_no_cons lhs, enum_class_no_cons rhs)
- {
- return lhs.val_ != rhs.val_;
- }
- //! not_equal operator
- friend bool operator!=(type lhs, enum_class_no_cons rhs)
- {
- return lhs != rhs.val_;
- }
- //! not_equal operator
- friend bool operator!=(enum_class_no_cons lhs, type rhs)
- {
- return lhs.val_ != rhs;
- }
- //! less_equal operator
- friend bool operator<=(enum_class_no_cons lhs, enum_class_no_cons rhs)
- {
- return lhs.val_ <= rhs.val_;
- }
- //! less_equal operator
- friend bool operator<=(type lhs, enum_class_no_cons rhs)
- {
- return lhs <= rhs.val_;
- }
- //! less_equal operator
- friend bool operator<=(enum_class_no_cons lhs, type rhs)
- {
- return lhs.val_ <= rhs;
- }
- //! less operator
- friend bool operator<(enum_class_no_cons lhs, enum_class_no_cons rhs)
- {
- return lhs.val_ < rhs.val_;
- }
- //! less operator
- friend bool operator<(type lhs, enum_class_no_cons rhs)
- {
- return lhs < rhs.val_;
- }
- //! less operator
- friend bool operator<(enum_class_no_cons lhs, type rhs)
- {
- return lhs.val_ < rhs;
- }
- //! greater_equal operator
- friend bool operator>=(enum_class_no_cons lhs, enum_class_no_cons rhs)
- {
- return lhs.val_ >= rhs.val_;
- }
- //! greater_equal operator
- friend bool operator>=(type lhs, enum_class_no_cons rhs)
- {
- return lhs >= rhs.val_;
- }
- //! greater_equal operator
- friend bool operator>=(enum_class_no_cons lhs, type rhs)
- {
- return lhs.val_ >= rhs;
- }
- //! greater operator
- friend bool operator>(enum_class_no_cons lhs, enum_class_no_cons rhs)
- {
- return lhs.val_ > rhs.val_;
- }
- //! greater operator
- friend bool operator>(type lhs, enum_class_no_cons rhs)
- {
- return lhs > rhs.val_;
- }
- //! greater operator
- friend bool operator>(enum_class_no_cons lhs, type rhs)
- {
- return lhs.val_ > rhs;
- }
-
- //! conversions from underlying_type to enum_type_cons following the Boost.Conversion protocol
- friend enum_class_no_cons convert_to(underlying_type v,
- boost::dummy::type_tag<enum_class_no_cons> const&)
- {
- enum_class_no_cons res;
- res.val_=v;
- return res;
- }
-
- //! friend conversions from type to enum_type_cons following the Boost.Conversion protocol
- friend enum_class_no_cons convert_to(type v,
- boost::dummy::type_tag<enum_class_no_cons> const&)
- {
- enum_class_no_cons res;
- res.val_=static_cast<underlying_type>(v);
- return res;
- }
-
- //! conversions from enum_type_cons to underlying_type following the Boost.Conversion protocol
- friend underlying_type convert_to(enum_class_no_cons v,
- boost::dummy::type_tag<underlying_type> const&)
- {
- return boost::enums::underlying_value(v);
- }
-
- //! conversions from enum_type_cons to type following the Boost.Conversion protocol
- friend type convert_to(enum_class_no_cons v,
- boost::dummy::type_tag<type> const&)
- {
- return boost::enums::enum_value(v);
- }
- };
- }
-}
-
-#endif // BOOST_ENUMS_ENUM_TYPE_MIXIN_HPP
Deleted: sandbox/enums/boost/enums/enum_range.hpp
==============================================================================
--- sandbox/enums/boost/enums/enum_range.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,163 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-/*!
- \file
- \brief
- The header \c <boost/enums/enum_range.hpp> defines a class template \c enum_range for viewing an enumerations as a range.
- */
-
-#ifndef BOOST_ENUMS_ENUM_RANGE_HPP
-#define BOOST_ENUMS_ENUM_RANGE_HPP
-
-#include <boost/enums/enum_type.hpp>
-//#include <boost/enums/enum_range_traits.hpp>
-#include <boost/enums/val.hpp>
-#include <boost/enums/pos.hpp>
-#include <boost/enums/size.hpp>
-
-
-#include <boost/iterator/iterator_facade.hpp>
-#include <boost/range/iterator_range.hpp>
-
-namespace boost {
- namespace enums {
- #ifndef BOOST_ENUMS_DOXYGEN_INVOKED
- namespace enums_detail {
- // enum_iterator is an iterator over an enum that
- // is bounded only by the limits of the enum.
- //
- // This is useful for implementing the enum_range<E>()
- // function.
- //
- // Note:
- // This use of this iterator and enum_range<E>() is appreciably less
- // performant than the corresponding hand-written integer
- // loop on many compilers.
-
- //! enum_iterator is a model of RandomAccessIterator
- template<typename EC /* , typename Traits=enum_range_traits<EC> */ >
- class enum_iterator
- : public boost::iterator_facade<
- enum_iterator<EC>,
- EC,
- boost::random_access_traversal_tag,
- EC,
- std::ptrdiff_t
- >
- {
- typedef boost::iterator_facade<
- enum_iterator<EC>,
- EC,
- boost::random_access_traversal_tag,
- EC,
- std::ptrdiff_t
- > base_t;
- public:
- typedef typename base_t::value_type value_type;
- typedef typename base_t::difference_type difference_type;
- typedef typename base_t::reference reference;
-
- enum_iterator() : index_(0) {}
- explicit enum_iterator(int x) : index_(x) {}
-
- private:
- void increment()
- {
- ++index_;
- }
-
- void decrement()
- {
- --index_;
- }
-
- void advance(difference_type offset)
- {
- index_ += offset;
- }
-
- difference_type distance_to(const enum_iterator& other) const
- {
- return other.index_ - index_;
- }
-
- bool equal(const enum_iterator& other) const
- {
- return index_ == other.index_;
- }
-
- reference dereference() const
- {
- return enums::val<EC>(index_);
- }
-
- friend class ::boost::iterator_core_access;
- int index_;
- };
- } // namespace enums_detail
- #endif
- //! \c enum_range is a model of the \e RandomAccessRange Concept associated to the enumeration \c EC.
-
-
- template<typename EC/* , typename Traits=enum_range_traits<EC> */ >
- class enum_range
- : public iterator_range< enums_detail::enum_iterator<EC/*, Traits*/> >
- {
- typedef enums_detail::enum_iterator<EC/*, Traits*/> iterator_t;
- typedef iterator_range<iterator_t> base_t;
- public:
- //! builds a enum range
- enum_range()
- : base_t(iterator_t(0), iterator_t(enums::meta::size<EC>::value))
- {
- }
-
- //! builds a enum sub-range
- enum_range(EC first, EC last)
- : base_t(iterator_t(enums::pos(first)),
- iterator_t(enums::pos(last)+1))
- {
- }
- };
-
- //! function to generate an enum range.
-
- //! \c make_range allows treating enums as a model of the \e RandomAccessRange Concept.
-
- //! \pre \c EC is a model of the \e Enumeration Concept.
-
- template<typename EC /*, typename Traits*/ >
- enum_range<EC>
- make_range()
- {
- return enum_range<EC/*,Traits*/>();
- }
-
- //! function to generate an enum sub-range.
-
- //! \c make_range allows treating enums as a model of the \e RandomAccessRange Concept.
- //! It should be noted that the first and last parameters denoted a closed range.
- //! \pre \c EC is a model of the \e Enumeration Concept.
- //! \param first first element of the range
- //! \param last last element of the range
- template<typename EC /*, typename Traits */ >
- enum_range<EC>
- make_range(EC first, EC last)
- {
- return enum_range<EC /*,Traits*/ >(first,last);
- }
-
- } // namespace enums
-} // namespace boost
-
-#endif
Deleted: sandbox/enums/boost/enums/enum_set.hpp
==============================================================================
--- sandbox/enums/boost/enums/enum_set.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,439 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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)
-//
-// Based on the boost/array.hpp implementation
-//
-// See http://www.boost.org/libs/enums for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-/*!
- \file
- \brief
- The header \c <boost/enums/enum_set.hpp> defines a class template \c enum_set<EC> for managing sets of enumeration and several
- //! related functions for representing and manipulating sets of enums. We can say that
- \c enum_set is the counterpart of \c std::bitset when the index are enums.
- */
-
-#ifndef BOOST_ENUMS_ENUM_SET_HPP
-#define BOOST_ENUMS_ENUM_SET_HPP
-
-//#include <boost/enums/enum_traits.hpp>
-//#include <boost/enums/val.hpp>
-#include <boost/enums/pos.hpp>
-#include <boost/enums/size.hpp>
-#include <bitset>
-#include <stdexcept>
-#include <iosfwd>
-#include <string>
-#include <cstddef>
-#include <climits>
-#include <string>
-#include <boost/functional/hash.hpp>
-
-#include <boost/config.hpp>
-
-namespace boost {
- namespace enums {
-
- template<typename EC /*,
- typename Traits=enum_subrange_traiter<EC>*/ >
- class enum_set
- {
- public:
- struct reference {
- };
- //! <b> Effects:</b> Constructs an object of class \c enum_set<>, initializing all
- //! enumerations to zero.
- BOOST_CONSTEXPR enum_set()
- {
- }
- //~ BOOST_CONSTEXPR
- // Need to be refactored to be a constexpr
- //~ error: constexpr constructor does not have empty body
- explicit enum_set(EC setting)
- {
- set(setting);
- }
-
- //! <b> Effects:</b> Constructs an object of class \c enum_set<>, initializing the
- //! first \c M bit positions to the corresponding bit values in \c val.
- //! \c M is the smaller of \c N and the number of bits in the value
- //! representation of \c unsigned \c long \c long. If \c M<N, the remaining bit
- //! positions are initialized to zero.
- BOOST_CONSTEXPR explicit enum_set(unsigned long long val)
- : bits(val)
- {
- }
- //#if defined(__GNUC__) && (__GNUC__ < 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ < 4 ))
- #if 1
- #else
-
- //! \pre <tt>pos <= str.size()</tt>.
- //! \throws out_of_range if <tt>pos > str.size()</tt>.
- //! <b> Effects:</b> Determines the effective length \c rlen of the initializing
- //! string as the smaller of \c n and <tt>str.size()-pos</tt>.
- //! The function then throws \c invalid_argument if any of the \c rlen
- //! characters in \c str beginning at position pos is other than zero or one.
- //! The function uses \c ch_traits::eq() to compare the character values.
- //! Otherwise, the function constructs an object of class \c enum_set<EC>,
- //! initializing the first \c M bit positions to values determined from the
- //! corresponding characters in the string \c str. \c M is the smaller of \c N and
- //! \c rlen.\n
- //! An element of the constructed string has value zero if the
- //! corresponding character in \c str, beginning at position \c pos, is \c 0 zero.
- //! Otherwise, the element has the value 1. Character position \c pos+M-1
- //! corresponds to bit position zero. Subsequent decreasing character
- //! positions correspond to increasing bit positions.
- //! If \c M<N, remaining bit positions are initialized to zero.
- template<class charT, class ch_traits, class TAllocator>
- explicit enum_set(const std::basic_string<charT,ch_traits,TAllocator>& str,
- typename std::basic_string<charT,ch_traits,TAllocator>::size_type pos = 0,
- typename std::basic_string<charT,ch_traits,TAllocator>::size_type n =
- std::basic_string<charT,ch_traits,TAllocator>::npos,
- charT zero = charT('0'), charT one = charT('1'))
- : bits(str, pos, n, zero, one)
- {}
-
- //! <b> Effects:</b> Constructs an object of class enum_set<N> as if by enum_set(string(str)).
- template <class charT>
- explicit enum_set(const charT* str,
- typename std::basic_string<charT>::size_type n = std::basic_string<charT>::npos,
- charT zero = charT('0'), charT one = charT('1'))
- : bits(str,n, zero, one)
- {}
- #endif
-
- //! <b> Effects:</b> Clears each bit in \c *this for which the corresponding bit in
- //! \c rhs is clear, and leaves all other bits unchanged.
- //! \returns \c *this.
- enum_set &operator&=(const enum_set &rhs)
- {
- bits &= rhs.bits;
- return *this;
- }
-
- //! <b> Effects:</b> Sets each bit in \c *this for which the corresponding bit in
- //! \c rhs is set, and leaves all other bits unchanged.
- //! \returns \c *this.
- enum_set &operator|=(const enum_set &rhs)
- {
- bits |= rhs.bits;
- return *this;
- }
-
- //! <b> Effects:</b> Toggles each bit in \c *this for which the corresponding bit in
- //! \c rhs is set, and leaves all other bits unchanged.
- //! \returns \c *this.
- enum_set &operator^=(const enum_set &rhs)
- {
- bits ^= rhs.bits;
- return *this;
- }
-
- //! <b> Effects:</b> Replaces each bit at position \c I in \c *this with a value determined as follows:
- //! - If \c I<pos, the new value is zero;
- //! - If \c I>=pos, the new value is the previous value of the bit at position \c I-pos.
- //! \returns \c *this.
- enum_set &operator<<=(const enum_set &rhs)
- {
- bits <<= rhs.bits;
- return *this;
- }
-
- //! <b> Effects:</b> Replaces each bit at position \c I in \c *this with a value determined as follows:
- //! - If \c pos>=N-I, the new value is zero;
- //! - If \c pos<N-I, the new value is the previous value of the bit at position \c I+pos.
- //! \returns \c *this.
-
- enum_set &operator>>=(const enum_set &rhs)
- {
- bits >>= rhs.bits;
- return *this;
- }
-
- //! \returns A count of the number of bits set in \c *this.
- std::size_t count() const
- {
- return bits.count();
- }
-
- //! \returns \c static_size.
- BOOST_CONSTEXPR std::size_t size() const
- {
- return bits.size();
- }
-
- //! \pre \c pos shall be valid.
- //! \throws nothing.
- //! \returns \c true if the bit at position \c pos in \c *this has the value one,
- //! otherwise \c false.
- BOOST_CONSTEXPR bool operator[](EC testing) const
- {
- return bits.test(to_bit(testing));
- }
-
- //! \pre \c pos shall be valid.
- //! \throws nothing.
- //! \returns An object of type \c enum_set<EC>::reference such that
- //! <tt>(*this)[pos] == this->test(pos)</tt>, and such that <tt>(*this)[pos] = val</tt> is
- //! equivalent to <tt>this->set(pos, val)</tt>.
- //! \note For the purpose of determining the presence of a data race,
- //! any access or update through the resulting reference potentially
- //! accesses or modifies, respectively, the entire underlying bitset.
- reference operator[](std::size_t pos); // for b[i];
-
- //! <b> Effects:</b> Sets all bits in \c *this.
- //! \returns \c *this.
-
- enum_set &set()
- {
- bits.set();
- return *this;
- }
-
- //! \pre \c setting is valid
- //! \throws out_of_range if \c pos does not correspond to a valid bit position.
- //! <b> Effects:</b> Stores a new value in the bit at the position associated to \c setting in \c *this.
- //! If \c value is nonzero, the stored value is one, otherwise it is zero.
- //! \returns \c *this.
- enum_set &set(EC setting, bool value = true)
- {
- bits.set(to_bit(setting), value);
- return *this;
- }
-
- //! <b> Effects:</b> Resets all bits in \c *this.
- //! \returns \c *this.
- enum_set &reset()
- {
- bits.reset();
- return *this;
- }
-
- //! \pre \c resetting is valid
- //! \throws out_of_range if \c resetting does not correspond to a valid enum.
- //! <b> Effects:</b> Resets the bit at the position associated to \c resetting in \c *this.
- //! \returns \c *this.
-
- enum_set &reset(EC resetting)
- {
- bits.reset(to_bit(resetting));
- return *this;
- }
-
- //! <b> Effects:</b> Toggles all bits in \c *this.
- //! \returns \c *this.
- enum_set &flip()
- {
- bits.flip();
- return *this;
- }
-
- //! \pre \c flipping is valid
- //! \throws out_of_range if \c flipping does not correspond to a valid enum.
- //! <b> Effects:</b> Toggles the bit at position associated to \c pos in \c *this.
- //! \returns \c *this.
- enum_set &flip(EC flipping)
- {
- bits.flip(to_bit(flipping));
- return *this;
- }
-
- //! \c <tt>unsigned long</tt> conversion
- //! \throws overflow_error if the integral value \c x corresponding to the
- //! bits in \c *this cannot be represented as type <<tt>unsigned long</tt>.
- //! \returns \c x.
-
- unsigned long to_ulong() const
- {
- return bits.to_ulong();
- }
-
- //! \c <tt>unsigned long long</tt> conversion
- //! \throws overflow_error if the integral value \c x corresponding to the
- //! bits in \c *this cannot be represented as type <tt>unsigned long long</tt>.
- //! \returns \c x.
- unsigned long long to_ullong() const
- {
- return bits.to_ulong();
- }
-#ifdef BOOST_ENUMS_DOXYGEN_INVOKED
-
- //! <b> Effects:</b> Constructs a string object of the appropriate type and
- //! initializes it to a string of length \c N characters. Each character is
- //! determined by the value of its corresponding bit position in \c *this.
- //! Character position \c N-1 corresponds to bit position zero.
- //! Subsequent decreasing character positions correspond to increasing
- //! bit positions. Bit value zero becomes the character zero, bit value
- //! one becomes the character one.
- //! \returns The created object.
- template <class charT = char,
- class traits = std::char_traits<charT>,
- class Allocator = std::allocator<charT> >
- std::basic_string<charT, traits, Allocator>
- to_string(charT zero = charT('0'), charT one = charT('1')) const;
-#endif
- //! <b> Effects:</b> Constructs an object x of class enum_set<EC> and initializes it with *this.
- //! \returns \c x.flip().
- enum_set operator~() const
- {
- return enum_set(*this).flip();
- }
-
- //! \pre \c testing is valid
- //! \throws out_of_range if the associated position of \c testing does not correspond to a valid bit position.
- //! \returns \c true if the bit at position \c pos in \c *this has the value one.
- bool test(EC testing);
-
- //! \returns <tt>count() == size()</tt>
- bool all() const
- {
- return bits.all();
- }
-
- //! \returns <tt>count() != 0</tt>
- bool any() const
- {
- return bits.any();
- }
-
- //! \returns <tt>count() == 0</tt>
- bool none() const
- {
- return bits.none();
- }
-
- //! \returns <tt>enum_set<EC>(*this) <<= pos</tt>.
- enum_set operator<<(std::size_t pos) const
- {
- enum_set r = *this;
- r <<= pos;
- return r;
- }
-
- //! \returns <tt>enum_set<EC>(*this) >>= pos</tt>.
- enum_set operator>>(std::size_t pos) const
- {
- enum_set r = *this;
- r >>= pos;
- return r;
- }
-
- //! \returns A nonzero value if the value of each bit in \c *this equals the
- //! value of the corresponding bit in \c rhs.
- bool operator==(const enum_set& rhs) const;
-
- //! \returns A nonzero value if <tt>!(*this == rhs)</tt>.
- bool operator!=(const enum_set& rhs) const;
- private:
-
- static std::size_t to_bit(EC value)
- {
- return enums::pos(value);
- }
-
- std::bitset<enums::meta::size<EC>::value> bits;
-
- public:
-
- std::bitset<enums::meta::size<EC>::value> detail_bits() { return bits; }
- };
-
- // enum_set operators:
-
- //! Intersection
-
- //! \returns enum_set<EC>(lhs) &= rhs.
- template <typename EC/*, typename Traits*/>
- enum_set<EC/*,Traits*/> operator&(const enum_set<EC/*,Traits*/>& x, const enum_set<EC/*,Traits*/>& y)
- {
- enum_set<EC/*,Traits*/> r = x;
- r &= y;
- return r;
- }
-
- //! Union
-
- //! \returns enum_set<EC>>(lhs) |= rhs.
- template <typename EC/*, typename Traits*/ >
- enum_set<EC/*,Traits*/> operator|(const enum_set<EC/*,Traits*/>& x, const enum_set<EC/*,Traits*/>& y)
- {
- enum_set<EC/*,Traits*/> r = x;
- r |= y;
- return r;
- }
-
- //! Exclusive union
-
- //! \returns enum_set<EC>(lhs) ^= rhs.
- template <typename EC/*, typename Traits*/ >
- enum_set<EC/*,Traits*/> operator^(const enum_set<EC/*,Traits*/>& x, const enum_set<EC/*,Traits*/>& y)
- {
- enum_set<EC/*,Traits*/> r = x;
- r ^= y;
- return r;
- }
-
- //! A formatted input function.
-
- //! \details <b> Effects:</b> Extracts up to \c N characters from is. Stores these characters
- //! in a temporary object \c str of type <tt>basic_string<charT, traits></tt>, then
- //! evaluates the expression <tt>x = enum_set<EC>(str)</tt>. Characters are extracted
- //! and stored until any of the following occurs:
- //! - \c N characters have been extracted and stored;
- //! - end-of-file occurs on the input sequence;
- //! - the next input character is neither \c is.widen('0') nor \c is.widen('1')
- //! (in which case the input character is not extracted).\n
- //! If no characters are stored in \c str, calls \c is.setstate(ios_base::failbit)
- //! (which may throw <tt>ios_- base::failure</tt>).
- //! \param is the input stream.
- //! \param x the \c enum_set.
- //! \returns \c is.
-
- template <class charT, class ch_traits, typename EC/*, typename Traits*/ >
- std::basic_istream<charT, ch_traits>&
- operator>>(std::basic_istream<charT, ch_traits>& is, enum_set<EC/*,Traits*/>& x)
- {
- return is >> x.detail_bits();
- }
-
- //! A formatted output function.
-
- //! \param os the output stream.
- //! \param x the \c enum_set.
- //! \returns <tt>os << x.template to_string<charT,traits,allocator<charT> >(
- //! use_facet<ctype<charT> >(os.getloc()).widen('0'),
- //! use_facet<ctype<charT> >(os.getloc()).widen('1'))</tt>
- template <class charT, class ch_traits, typename EC/*, typename Traits*/ >
- std::basic_ostream<charT, ch_traits>&
- operator<<(std::basic_ostream<charT, ch_traits>& os, const enum_set<EC/*,Traits*/>& x)
- {
- return os << x.detail_bits();
- }
-
-
- } /* namespace enums */
-
- //! hash template specialization
-
- template <typename EC/*, typename Traits*/ >
- struct hash<enums::enum_set<EC/*,Traits*/> >
- : public std::unary_function<enums::enum_set<EC/*,Traits*/>, std::size_t>
- {
- //! \details the template specialization meets the requirements of class template \c hash.
- std::size_t operator()(const enums::enum_set<EC/*,Traits*/>& bs) const
- {
- return hash<std::bitset<enums::meta::size<EC>::size> >(bs.detail_bits());
- }
- };
-
-} /* namespace boost */
-
-
-#endif /*BOOST_ENUMS_ENUM_SET_HPP*/
Modified: sandbox/enums/boost/enums/enum_subrange.hpp
==============================================================================
--- sandbox/enums/boost/enums/enum_subrange.hpp (original)
+++ sandbox/enums/boost/enums/enum_subrange.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -13,10 +13,10 @@
#ifndef BOOST_ENUMS_ENUM_SUBRANGE_HPP
#define BOOST_ENUMS_ENUM_SUBRANGE_HPP
-#include <boost/enums/pos.hpp>
-#include <boost/enums/first.hpp>
-#include <boost/enums/last.hpp>
-#include <boost/enums/scoping_type.hpp>
+#include <boost/enums/ordinal/pos.hpp>
+#include <boost/enums/ordinal/first.hpp>
+#include <boost/enums/ordinal/last.hpp>
+#include <boost/enums/scoped/scoping_type.hpp>
namespace boost {
namespace enums {
Modified: sandbox/enums/boost/enums/enum_subrange_traiter.hpp
==============================================================================
--- sandbox/enums/boost/enums/enum_subrange_traiter.hpp (original)
+++ sandbox/enums/boost/enums/enum_subrange_traiter.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -13,10 +13,10 @@
#ifndef BOOST_ENUMS_ENUM_SUBRANGE_HPP
#define BOOST_ENUMS_ENUM_SUBRANGE_HPP
-#include <boost/enums/pos.hpp>
-#include <boost/enums/first.hpp>
-#include <boost/enums/last.hpp>
-#include <boost/enums/scoping_type.hpp>
+#include <boost/enums/ordinal/pos.hpp>
+#include <boost/enums/ordinal/first.hpp>
+#include <boost/enums/ordinal/last.hpp>
+#include <boost/enums/scoped/scoping_type.hpp>
namespace boost {
namespace enums {
Deleted: sandbox/enums/boost/enums/enum_traiter.hpp
==============================================================================
--- sandbox/enums/boost/enums/enum_traiter.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,90 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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 BOOST_ENUMS_ENUM_TRAITER_HPP
-#define BOOST_ENUMS_ENUM_TRAITER_HPP
-
-#include <boost/enums/enum_type.hpp>
-#include <boost/enums/size.hpp>
-#include <boost/enums/val.hpp>
-#include <boost/enums/pos.hpp>
-#include <boost/enums/first.hpp>
-#include <boost/enums/last.hpp>
-#include <boost/conversion/convert_to.hpp>
-
-/*!
- \file
- \brief
- The header \c <boost/enums/linear_enum_traiter.hpp> declares a class template
- \c meta::linear_enum_traiter<> which can be used as \c enum_trait<> helper for enumerations having a linear progression.
- */
-
-namespace boost {
- namespace enums {
-
- //! Helper class used as \c enum_trait<> for enumerations having a linear progression.
- template <
- typename EC
- >
- struct linear_enum_traiter
- {
- private:
- BOOST_STATIC_CONSTEXPR typename underlying_type<EC>::type first_value =
- static_cast<typename underlying_type<EC>::type>(
- enums::meta::val<EC,0>::value
- );
- BOOST_STATIC_CONSTEXPR typename underlying_type<EC>::type last_value =
- static_cast<typename underlying_type<EC>::type>(
- enums::meta::val<EC,meta::size<EC>::value-1>::value
- );
- BOOST_STATIC_CONSTEXPR std::size_t step = (last_value-first_value)/(meta::size<EC>::value-1);
- public:
- //! pos specialization.
-
- //! \returns the returned value is calculated from the underlying value,
- //! the \c first_value and the \c step, following this formula \c (ut-first_value)/step
- static std::size_t pos(EC e)
- {
- typename underlying_type<EC>::type uv = underlying_value(e);
- return (uv-first_value)/step;
- }
- //! val specialization.
-
- //! \returns the returned value is calculated from the position \c p,
- //! the first value and the step, following this formula \c p*step+first_value
- static EC val(std::size_t p)
- {
- typename underlying_type<EC>::type uv = p*step+first_value;
- return boost::convert_to<EC>(uv);
- }
- };
-
-// template <
-// typename EC
-// >
-// struct log2_enum_traiter
-// {
-// public:
-// static std::size_t pos(EC e)
-// {
-// return (enum_value(e));
-// }
-// static EC val(std::size_t i)
-// {
-// typename underlying_type<EC>::type ut = 1<<i;
-// return boost::convert_to<EC>(ut);
-// }
-// };
- }
-}
-
-#endif
Deleted: sandbox/enums/boost/enums/enum_traits.hpp
==============================================================================
--- sandbox/enums/boost/enums/enum_traits.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,46 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-/*!
- \file
- \brief
- The header \c <boost/enums/enum_traits.hpp> declares a class template
- \c meta::enum_traits<> which must be specialized for each enumeration including two static functions \c pos() and \c val().
- */
-
-#ifndef BOOST_ENUMS_ENUM_TRAITS_HPP
-#define BOOST_ENUMS_ENUM_TRAITS_HPP
-
-namespace boost
-{
- namespace enums
- {
- namespace meta
- {
- template <typename EC>
-#ifndef BOOST_ENUMS_DOXYGEN_INVOKED
- struct enum_traits;
-#else
- struct enum_traits
- {
- //! The specialization must define this function prototype
- static std::size_t pos(EC e);
- //! The specialization must define this function prototype
- static EC val(std::size_t p);
- };
-#endif
-
- }
- }
-}
-
-#endif
Deleted: sandbox/enums/boost/enums/enum_type.hpp
==============================================================================
--- sandbox/enums/boost/enums/enum_type.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,40 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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 BOOST_ENUMS_ENUM_TYPE_HPP
-#define BOOST_ENUMS_ENUM_TYPE_HPP
-
-#include <boost/config.hpp>
-
-namespace boost
-{
- namespace enums
- {
- //! meta-function to get the native enum type associated to an enum class
- //! or its emulation
- template <typename EC>
- struct enum_type
- {
-#ifndef BOOST_ENUMS_DOXYGEN_INVOKED
- #ifdef BOOST_NO_SCOPED_ENUMS
- typedef typename EC::type type;
- #else
- typedef EC type;
- #endif
-#else
- typedef <see below> type;
-#endif
- };
- }
-}
-
-#endif
Deleted: sandbox/enums/boost/enums/enum_type_cons.hpp
==============================================================================
--- sandbox/enums/boost/enums/enum_type_cons.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,250 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-/*!
- \file
- \brief
- The header \c <boost/enums/enum_type_cons.hpp> defines the declaration of enum_type_cons<> template class.
- */
-
-#ifndef BOOST_ENUMS_ENUM_TYPE_CONS_HPP
-#define BOOST_ENUMS_ENUM_TYPE_CONS_HPP
-
-#include <boost/config.hpp>
-
-namespace boost
-{
- namespace enums
- {
- //! scoped enum type with constructors
-
- //! param @c ScopedEnum : Struct scoping the enum.\n
- //! param @c UT : the underlaying storage type.\n
- //! pre @c ScopedEnum must have a nested C++98 enum @c type.\n
- template <typename ScopedEnum, typename UT=int>
- class enum_type_cons : public ScopedEnum
- {
- public:
- //! c++98 enum type
- typedef typename ScopedEnum::type type;
- //! underlying type
- typedef UT underlying_type;
- private:
- underlying_type val_;
- public:
- //! default constructor
- enum_type_cons()
- : val_(static_cast<underlying_type>(type()))
- {
- }
-
- //! explicit constructor from underlying type
- explicit enum_type_cons(underlying_type v)
- : val_(v)
- {
- }
-
- //! constructor from enum type
- enum_type_cons(type v)
- : val_(static_cast<underlying_type>(v))
- {
- }
-
-#if 0
- //! implicit conversion to underlying_type
- operator underlying_type()
- {
- return val_;
- }
-#endif
- //! implicit conversion to enum type
- operator type()
- {
- return type(val_);
- }
-
- //! assignment
- enum_type_cons& operator=(enum_type_cons rhs)
- {
- val_=rhs.val_;
- return *this;
- }
- //! assignment from enum literals
- enum_type_cons& operator=(type rhs)
- {
- val_=static_cast<underlying_type>(rhs);
- return *this;
- }
- //! workaround in case there are no constructors
- static enum_type_cons default_value()
- {
- enum_type_cons res;
- res.val_=static_cast<underlying_type>(type());
- return res;
- }
-
- static enum_type_cons convert_to(underlying_type v)
- {
- enum_type_cons res;
- res.val_=v;
- return res;
-
- }
-
- static enum_type_cons convert_to(type v)
- {
- enum_type_cons res;
- res.val_=static_cast<underlying_type>(v);
- return res;
- }
-
- //! explicit conversion function to enum type
- type enum_value() const
- {
- return type(val_);
- }
-
- //! explicit conversion function to underlying_type
- underlying_type underlying_value() const
- {
- return val_;
- }
-#if 0
- //! equal operator
- friend bool operator==(enum_type_cons lhs, enum_type_cons rhs)
- {
- return lhs.val_ == rhs.val_;
- }
- //! equal operator
- friend bool operator==(type lhs, enum_type_cons rhs)
- {
- return lhs == rhs.val_;
- }
-
- //! equal operator
- friend bool operator==(enum_type_cons lhs, type rhs)
- {
- return lhs.val_ == rhs;
- }
- //! not_equal operator
- friend bool operator!=(enum_type_cons lhs, enum_type_cons rhs)
- {
- return lhs.val_ != rhs.val_;
- }
- //! not_equal operator
- friend bool operator!=(type lhs, enum_type_cons rhs)
- {
- return lhs != rhs.val_;
- }
- //! not_equal operator
- friend bool operator!=(enum_type_cons lhs, type rhs)
- {
- return lhs.val_ != rhs;
- }
- //! less_equal operator
- friend bool operator<=(enum_type_cons lhs, enum_type_cons rhs)
- {
- return lhs.val_ <= rhs.val_;
- }
- //! less_equal operator
- friend bool operator<=(type lhs, enum_type_cons rhs)
- {
- return lhs <= rhs.val_;
- }
- //! less_equal operator
- friend bool operator<=(enum_type_cons lhs, type rhs)
- {
- return lhs.val_ <= rhs;
- }
- //! less operator
- friend bool operator<(enum_type_cons lhs, enum_type_cons rhs)
- {
- return lhs.val_ < rhs.val_;
- }
- //! less operator
- friend bool operator<(type lhs, enum_type_cons rhs)
- {
- return lhs < rhs.val_;
- }
- //! less operator
- friend bool operator<(enum_type_cons lhs, type rhs)
- {
- return lhs.val_ < rhs;
- }
- //! greater_equal operator
- friend bool operator>=(enum_type_cons lhs, enum_type_cons rhs)
- {
- return lhs.val_ >= rhs.val_;
- }
- //! greater_equal operator
- friend bool operator>=(type lhs, enum_type_cons rhs)
- {
- return lhs >= rhs.val_;
- }
- //! greater_equal operator
- friend bool operator>=(enum_type_cons lhs, type rhs)
- {
- return lhs.val_ >= rhs;
- }
- //! greater operator
- friend bool operator>(enum_type_cons lhs, enum_type_cons rhs)
- {
- return lhs.val_ > rhs.val_;
- }
- //! greater operator
- friend bool operator>(type lhs, enum_type_cons rhs)
- {
- return lhs > rhs.val_;
- }
- //! greater operator
- friend bool operator>(enum_type_cons lhs, type rhs)
- {
- return lhs.val_ > rhs;
- }
-#endif
-#if 0
- //! conversions from underlying_type to enum_type_cons following the Boost.Conversion protocol
- friend enum_type_cons convert_to(underlying_type v,
- boost::dummy::type_tag<enum_type_cons> const&)
- {
- enum_type_cons res;
- res.val_=v;
- return res;
-
- }
-
- //! friend conversions from type to enum_type_cons following the Boost.Conversion protocol
- friend enum_type_cons convert_to(type v,
- boost::dummy::type_tag<enum_type_cons> const&)
- {
- enum_type_cons res;
- res.val_=static_cast<underlying_type>(v);
- return res;
- }
-#endif
- //! conversions from enum_type_cons to underlying_type following the Boost.Conversion protocol
- friend underlying_type convert_to(enum_type_cons v,
- boost::dummy::type_tag<underlying_type> const&)
- {
- return boost::enums::underlying_value(v);
- }
- //! conversions from enum_type_cons to type following the Boost.Conversion protocol
- friend type convert_to(enum_type_cons v,
- boost::dummy::type_tag<type> const&)
- {
- return boost::enums::enum_value(v);
- }
- };
- }
-}
-
-#endif // BOOST_ENUMS_ENUM_TYPE_MIXIN_HPP
Deleted: sandbox/enums/boost/enums/enum_type_no_cons.hpp
==============================================================================
--- sandbox/enums/boost/enums/enum_type_no_cons.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,234 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-/*!
- \file
- \brief
- The header \c <boost/enums/enum_type_no_cons.hpp> defines the declaration of enum_type_no_cons<> template class.
- */
-
-#ifndef BOOST_ENUMS_ENUM_TYPE_NO_CONS_HPP
-#define BOOST_ENUMS_ENUM_TYPE_NO_CONS_HPP
-
-#include <boost/config.hpp>
-
-namespace boost
-{
- namespace enums
- {
- //! scoped enum type without constructors
-
- //! param @c ScopedEnum : Struct scoping the enum.\n
- //! param @c UT : the underlaying storage type.\n
- //! pre @c ScopedEnum must have a nested C++98 enum @c type.\n
- template <typename ScopedEnum, typename UT=int>
- class enum_type_no_cons : public ScopedEnum
- {
- public:
- //! c++98 enum type
- typedef typename ScopedEnum::type type;
- //! underlying type
- typedef UT underlying_type;
- private:
- underlying_type val_;
- public:
-
-#if 0
- //! implicit conversion to underlying_type
- operator underlying_type()
- {
- return val_;
- }
-#endif
-
- //! implicit conversion to enum type
- operator type()
- {
- return type(val_);
- }
-
- //! assignment
- enum_type_no_cons& operator=(enum_type_no_cons rhs)
- {
- val_=rhs.val_;
- return *this;
- }
-
- //! assignment from enum literals
- enum_type_no_cons& operator=(type rhs)
- {
- val_=static_cast<underlying_type>(rhs);
- return *this;
- }
-
- //! workaround in case there are no constructors
- static enum_type_no_cons default_value()
- {
- enum_type_no_cons res;
- res.val_=static_cast<underlying_type>(type());
- return res;
- }
-
- static enum_type_no_cons convert_to(underlying_type v)
- {
- enum_type_no_cons res;
- res.val_=v;
- return res;
-
- }
-
- static enum_type_no_cons convert_to(type v)
- {
- enum_type_no_cons res;
- res.val_=static_cast<underlying_type>(v);
- return res;
- }
- //! explicit conversion function to enum type
- type enum_value() const
- {
- return type(val_);
- }
- //! explicit conversion function to underlying_type
- underlying_type underlying_value() const
- {
- return val_;
- }
-#if 0
-
- //! equal operator
- friend bool operator==(enum_type_no_cons lhs, enum_type_no_cons rhs)
- {
- return lhs.val_ == rhs.val_;
- }
- //! equal operator
- friend bool operator==(type lhs, enum_type_no_cons rhs)
- {
- return lhs == rhs.val_;
- }
- //! equal operator
- friend bool operator==(enum_type_no_cons lhs, type rhs)
- {
- return lhs.val_ == rhs;
- }
- //! not_equal operator
- friend bool operator!=(enum_type_no_cons lhs, enum_type_no_cons rhs)
- {
- return lhs.val_ != rhs.val_;
- }
- //! not_equal operator
- friend bool operator!=(type lhs, enum_type_no_cons rhs)
- {
- return lhs != rhs.val_;
- }
- //! not_equal operator
- friend bool operator!=(enum_type_no_cons lhs, type rhs)
- {
- return lhs.val_ != rhs;
- }
- //! less_equal operator
- friend bool operator<=(enum_type_no_cons lhs, enum_type_no_cons rhs)
- {
- return lhs.val_ <= rhs.val_;
- }
- //! less_equal operator
- friend bool operator<=(type lhs, enum_type_no_cons rhs)
- {
- return lhs <= rhs.val_;
- }
- //! less_equal operator
- friend bool operator<=(enum_type_no_cons lhs, type rhs)
- {
- return lhs.val_ <= rhs;
- }
- //! less operator
- friend bool operator<(enum_type_no_cons lhs, enum_type_no_cons rhs)
- {
- return lhs.val_ < rhs.val_;
- }
- //! less operator
- friend bool operator<(type lhs, enum_type_no_cons rhs)
- {
- return lhs < rhs.val_;
- }
- //! less operator
- friend bool operator<(enum_type_no_cons lhs, type rhs)
- {
- return lhs.val_ < rhs;
- }
- //! greater_equal operator
- friend bool operator>=(enum_type_no_cons lhs, enum_type_no_cons rhs)
- {
- return lhs.val_ >= rhs.val_;
- }
- //! greater_equal operator
- friend bool operator>=(type lhs, enum_type_no_cons rhs)
- {
- return lhs >= rhs.val_;
- }
- //! greater_equal operator
- friend bool operator>=(enum_type_no_cons lhs, type rhs)
- {
- return lhs.val_ >= rhs;
- }
- //! greater operator
- friend bool operator>(enum_type_no_cons lhs, enum_type_no_cons rhs)
- {
- return lhs.val_ > rhs.val_;
- }
- //! greater operator
- friend bool operator>(type lhs, enum_type_no_cons rhs)
- {
- return lhs > rhs.val_;
- }
- //! greater operator
- friend bool operator>(enum_type_no_cons lhs, type rhs)
- {
- return lhs.val_ > rhs;
- }
-#endif
-
- //! conversions from underlying_type to enum_type_cons following the Boost.Conversion protocol
- friend enum_type_no_cons convert_to(underlying_type v,
- boost::dummy::type_tag<enum_type_no_cons> const&)
- {
- enum_type_no_cons res;
- res.val_=v;
- return res;
- }
-
- //! friend conversions from type to enum_type_cons following the Boost.Conversion protocol
- friend enum_type_no_cons convert_to(type v,
- boost::dummy::type_tag<enum_type_no_cons> const&)
- {
- enum_type_no_cons res;
- res.val_=static_cast<underlying_type>(v);
- return res;
- }
-
- //! conversions from enum_type_cons to underlying_type following the Boost.Conversion protocol
- friend underlying_type convert_to(enum_type_no_cons v,
- boost::dummy::type_tag<underlying_type> const&)
- {
- return boost::enums::underlying_value(v);
- }
-
- //! conversions from enum_type_cons to type following the Boost.Conversion protocol
- friend type convert_to(enum_type_no_cons v,
- boost::dummy::type_tag<type> const&)
- {
- return boost::enums::enum_value(v);
- }
- };
- }
-}
-
-#endif // BOOST_ENUMS_ENUM_TYPE_MIXIN_HPP
Deleted: sandbox/enums/boost/enums/enum_value.hpp
==============================================================================
--- sandbox/enums/boost/enums/enum_value.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,35 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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 BOOST_ENUMS_ENUM_VALUE_HPP
-#define BOOST_ENUMS_ENUM_VALUE_HPP
-
-#include <boost/config.hpp>
-#include <boost/enums/enum_type.hpp>
-
-namespace boost {
- namespace enums {
-
- template <typename EC>
- inline
- typename enum_type<EC>::type enum_value(EC e)
- {
-#ifdef BOOST_NO_SCOPED_ENUMS
- return e.enum_value();
-#else
- return e;
-#endif
- }
- }
-}
-
-#endif
Deleted: sandbox/enums/boost/enums/first.hpp
==============================================================================
--- sandbox/enums/boost/enums/first.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,43 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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 BOOST_ENUMS_FIRST_HPP
-#define BOOST_ENUMS_FIRST_HPP
-
-#include <boost/enums/enum_type.hpp>
-#include <boost/enums/val.hpp>
-
-namespace boost
-{
- namespace enums
- {
- namespace meta
- {
- //! meta-function: first element of an enumeration
- template <typename EC>
- struct first
- {
- BOOST_STATIC_CONSTEXPR typename enum_type<EC>::type value = enums::meta::val<EC,0>::value;
- };
- }
- //! Returns the the first element of an enumeration
- //! Throws: Nothing
- template <typename EC>
- BOOST_CONSTEXPR EC first()
- {
- return meta::first<EC>::value;
- }
- }
-}
-
-#endif
Deleted: sandbox/enums/boost/enums/get_value.hpp
==============================================================================
--- sandbox/enums/boost/enums/get_value.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,36 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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 BOOST_ENUMS_GET_VALUE_HPP
-#define BOOST_ENUMS_GET_VALUE_HPP
-
-#include <boost/config.hpp>
-#include <boost/enums/enum_type.hpp>
-
-namespace boost {
- namespace enums {
-
- template <typename EC>
- inline
- typename enum_type<EC>::type
- get_value(EC e)
- {
-#ifdef BOOST_NO_SCOPED_ENUMS
- return e.get();
-#else
- return e;
-#endif
- }
- }
-}
-
-#endif
Modified: sandbox/enums/boost/enums/include.hpp
==============================================================================
--- sandbox/enums/boost/enums/include.hpp (original)
+++ sandbox/enums/boost/enums/include.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -13,23 +13,10 @@
#ifndef BOOST_ENUMS_INCLUDE_HPP
#define BOOST_ENUMS_INCLUDE_HPP
-#include <boost/enums/default_value.hpp>
-#include <boost/enums/emulation.hpp>
-#include <boost/enums/enum_array.hpp>
-#include <boost/enums/enum_range.hpp>
-#include <boost/enums/enum_set.hpp>
-#include <boost/enums/enum_traiter.hpp>
-#include <boost/enums/enum_traits.hpp>
-#include <boost/enums/enum_type.hpp>
-#include <boost/enums/enum_value.hpp>
-#include <boost/enums/first.hpp>
-#include <boost/enums/last.hpp>
-#include <boost/enums/pos.hpp>
-#include <boost/enums/pred.hpp>
-#include <boost/enums/size.hpp>
-#include <boost/enums/succ.hpp>
-#include <boost/enums/underlying_type.hpp>
-#include <boost/enums/val.hpp>
+#include <boost/enums/scoped.hpp>
+#include <boost/enums/ordinal.hpp>
+#include <boost/enums/containers.hpp>
+#include <boost/enums/mpl.hpp>
#endif
Deleted: sandbox/enums/boost/enums/last.hpp
==============================================================================
--- sandbox/enums/boost/enums/last.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,50 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-/*!
- \file
- \brief
- The header \c <boost/enums/last.hpp> declares a class template \c meta::last<> and
- a function \c last() returning the last element of an enumeration.
- */
-
-#ifndef BOOST_ENUMS_LAST_HPP
-#define BOOST_ENUMS_LAST_HPP
-
-#include <boost/enums/enum_type.hpp>
-#include <boost/enums/val.hpp>
-#include <boost/enums/size.hpp>
-
-namespace boost
-{
- namespace enums
- {
- namespace meta
- {
- //! meta-function: first element of an enumeration
- template <typename EC>
- struct last
- {
- BOOST_STATIC_CONSTEXPR typename enum_type<EC>::type value = val<EC,size<EC>::value-1>::value;
- };
- }
- //! Returns the the last element of an enumeration
- //! Throws: Nothing
- template <typename EC>
- BOOST_CONSTEXPR EC last()
- {
- return meta::val<EC,meta::size<EC>::value-1>::value;
- }
- }
-}
-
-#endif
Modified: sandbox/enums/boost/enums/mpl/aux_/enum_range_c/iterator.hpp
==============================================================================
--- sandbox/enums/boost/enums/mpl/aux_/enum_range_c/iterator.hpp (original)
+++ sandbox/enums/boost/enums/mpl/aux_/enum_range_c/iterator.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -25,8 +25,8 @@
#include <boost/mpl/minus.hpp>
#include <boost/mpl/aux_/value_wknd.hpp>
#include <boost/mpl/aux_/config/ctps.hpp>
-#include <boost/enums/size.hpp>
-#include <boost/enums/val.hpp>
+#include <boost/enums/ordinal/size.hpp>
+#include <boost/enums/ordinal/val.hpp>
#include <boost/enums/mpl/aux_/enum_range_c/tag.hpp>
#include <boost/mpl/integral_c.hpp>
#include <boost/mpl/eval_if.hpp>
Modified: sandbox/enums/boost/enums/mpl/enum_c.hpp
==============================================================================
--- sandbox/enums/boost/enums/mpl/enum_c.hpp (original)
+++ sandbox/enums/boost/enums/mpl/enum_c.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -14,8 +14,8 @@
#define BOOST_ENUMS_ENUM_C_HPP
#include <boost/enums/mpl/enum_c_tag.hpp>
-#include <boost/enums/enum_type.hpp>
-#include <boost/enums/underlying_type.hpp>
+#include <boost/enums/scoped/native_type.hpp>
+#include <boost/enums/scoped/underlying_type.hpp>
#include <cstddef>
namespace boost {
Modified: sandbox/enums/boost/enums/mpl/enum_range_c.hpp
==============================================================================
--- sandbox/enums/boost/enums/mpl/enum_range_c.hpp (original)
+++ sandbox/enums/boost/enums/mpl/enum_range_c.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -24,8 +24,8 @@
#include <boost/enums/mpl/aux_/enum_range_c/empty.hpp>
#include <boost/enums/mpl/aux_/enum_range_c/iterator.hpp>
#include <boost/enums/mpl/aux_/enum_range_c/tag.hpp>
-#include <boost/enums/size.hpp>
-#include <boost/enums/val.hpp>
+#include <boost/enums/ordinal/size.hpp>
+#include <boost/enums/ordinal/val.hpp>
#include <boost/mpl/integral_c.hpp>
#include <cstddef>
Added: sandbox/enums/boost/enums/ordinal.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/ordinal.hpp 2011-03-17 19:21:17 EDT (Thu, 17 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_ENUMS_ORDINAL_HPP
+#define BOOST_ENUMS_ORDINAL_HPP
+
+//#include <boost/enums/ordinal/macros.hpp>
+#include <boost/enums/ordinal/first.hpp>
+#include <boost/enums/ordinal/last.hpp>
+#include <boost/enums/ordinal/pred.hpp>
+#include <boost/enums/ordinal/succ.hpp>
+#include <boost/enums/ordinal/size.hpp>
+#include <boost/enums/ordinal/pos.hpp>
+#include <boost/enums/ordinal/val.hpp>
+#include <boost/enums/ordinal/traits.hpp>
+#include <boost/enums/ordinal/linear_traiter.hpp>
+
+#endif // BOOST_ENUMS_ORDINAL_HPP
Added: sandbox/enums/boost/enums/ordinal/first.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/ordinal/first.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -0,0 +1,43 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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 BOOST_ENUMS_ORDINAL_FIRST_HPP
+#define BOOST_ENUMS_ORDINAL_FIRST_HPP
+
+#include <boost/enums/scoped/native_type.hpp>
+#include <boost/enums/ordinal/val.hpp>
+
+namespace boost
+{
+ namespace enums
+ {
+ namespace meta
+ {
+ //! meta-function: first element of an enumeration
+ template <typename EC>
+ struct first
+ {
+ BOOST_STATIC_CONSTEXPR typename enum_type<EC>::type value = enums::meta::val<EC,0>::value;
+ };
+ }
+ //! Returns the the first element of an enumeration
+ //! Throws: Nothing
+ template <typename EC>
+ BOOST_CONSTEXPR EC first()
+ {
+ return meta::first<EC>::value;
+ }
+ }
+}
+
+#endif // BOOST_ENUMS_ORDINAL_FIRST_HPP
Added: sandbox/enums/boost/enums/ordinal/last.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/ordinal/last.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -0,0 +1,50 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/*!
+ \file
+ \brief
+ The header \c <boost/enums/last.hpp> declares a class template \c meta::last<> and
+ a function \c last() returning the last element of an enumeration.
+ */
+
+#ifndef BOOST_ENUMS_ORDINAL_LAST_HPP
+#define BOOST_ENUMS_ORDINAL_LAST_HPP
+
+#include <boost/enums/scoped/native_type.hpp>
+#include <boost/enums/ordinal/val.hpp>
+#include <boost/enums/ordinal/size.hpp>
+
+namespace boost
+{
+ namespace enums
+ {
+ namespace meta
+ {
+ //! meta-function: first element of an enumeration
+ template <typename EC>
+ struct last
+ {
+ BOOST_STATIC_CONSTEXPR typename enum_type<EC>::type value = val<EC,size<EC>::value-1>::value;
+ };
+ }
+ //! Returns the the last element of an enumeration
+ //! Throws: Nothing
+ template <typename EC>
+ BOOST_CONSTEXPR EC last()
+ {
+ return meta::val<EC,meta::size<EC>::value-1>::value;
+ }
+ }
+}
+
+#endif // BOOST_ENUMS_ORDINAL_LAST_HPP
Added: sandbox/enums/boost/enums/ordinal/linear_traiter.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/ordinal/linear_traiter.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -0,0 +1,90 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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 BOOST_ENUMS_ORDINAL_LINEAR_TRAITER_HPP
+#define BOOST_ENUMS_ORDINAL_LINEAR_TRAITER_HPP
+
+#include <boost/enums/scoped/native_type.hpp>
+#include <boost/enums/ordinal/size.hpp>
+#include <boost/enums/ordinal/val.hpp>
+#include <boost/enums/ordinal/pos.hpp>
+#include <boost/enums/ordinal/first.hpp>
+#include <boost/enums/ordinal/last.hpp>
+#include <boost/conversion/convert_to.hpp>
+
+/*!
+ \file
+ \brief
+ The header \c <boost/enums/linear_enum_traiter.hpp> declares a class template
+ \c meta::linear_enum_traiter<> which can be used as \c enum_trait<> helper for enumerations having a linear progression.
+ */
+
+namespace boost {
+ namespace enums {
+
+ //! Helper class used as \c enum_trait<> for enumerations having a linear progression.
+ template <
+ typename EC
+ >
+ struct linear_enum_traiter
+ {
+ private:
+ BOOST_STATIC_CONSTEXPR typename underlying_type<EC>::type first_value =
+ static_cast<typename underlying_type<EC>::type>(
+ enums::meta::val<EC,0>::value
+ );
+ BOOST_STATIC_CONSTEXPR typename underlying_type<EC>::type last_value =
+ static_cast<typename underlying_type<EC>::type>(
+ enums::meta::val<EC,meta::size<EC>::value-1>::value
+ );
+ BOOST_STATIC_CONSTEXPR std::size_t step = (last_value-first_value)/(meta::size<EC>::value-1);
+ public:
+ //! pos specialization.
+
+ //! \returns the returned value is calculated from the underlying value,
+ //! the \c first_value and the \c step, following this formula \c (ut-first_value)/step
+ static std::size_t pos(EC e)
+ {
+ typename underlying_type<EC>::type uv = underlying_value(e);
+ return (uv-first_value)/step;
+ }
+ //! val specialization.
+
+ //! \returns the returned value is calculated from the position \c p,
+ //! the first value and the step, following this formula \c p*step+first_value
+ static EC val(std::size_t p)
+ {
+ typename underlying_type<EC>::type uv = p*step+first_value;
+ return boost::convert_to<EC>(uv);
+ }
+ };
+
+// template <
+// typename EC
+// >
+// struct log2_enum_traiter
+// {
+// public:
+// static std::size_t pos(EC e)
+// {
+// return (enum_value(e));
+// }
+// static EC val(std::size_t i)
+// {
+// typename underlying_type<EC>::type ut = 1<<i;
+// return boost::convert_to<EC>(ut);
+// }
+// };
+ }
+}
+
+#endif // BOOST_ENUMS_ORDINAL_LINEAR_TRAITER_HPP
Added: sandbox/enums/boost/enums/ordinal/pos.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/ordinal/pos.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -0,0 +1,68 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/*!
+ \file
+ \brief
+ The header \c <boost/enums/pos.hpp> declares a class template \c meta::pos<> and
+ a function \c pos() associating the an element of an enumeration to
+ its relative position.
+ */
+
+#ifndef BOOST_ENUMS_ORDINAL_POS_HPP
+#define BOOST_ENUMS_ORDINAL_POS_HPP
+
+#include <boost/enums/scoped/native_type.hpp>
+#include <boost/enums/ordinal/traits.hpp>
+#include <cstddef>
+
+
+namespace boost
+{
+ namespace enums
+ {
+ namespace meta
+ {
+ //! meta-function used to associate the an element of an enumeration to
+ //! its relative position.
+
+ //! \note This meta-function must be specialized for each element of the enumeration.
+ template <typename EC, typename enum_type<EC>::type V>
+#ifndef BOOST_ENUMS_DOXYGEN_INVOKED
+ struct pos;
+#else
+ struct pos
+ {
+ constexpr std::size_t value=<to be defined for each specialization>;
+ };
+#endif
+ }
+
+
+ //! position of an enum literal \c e on the extension of the enumeration type \c EC.
+
+ //! The \c enum_traits class must be specialized and contain a \c pos function
+ //! that returns the relative position of its argument \c e.
+
+ //! \param e the enum literal
+ //! \returns the associated position
+ //! \throws Nothing
+ template <typename EC>
+ std::size_t pos(EC e)
+ {
+ return meta::enum_traits<EC>::pos(e);
+ }
+
+ }
+}
+
+#endif // BOOST_ENUMS_ORDINAL_POS_HPP
Added: sandbox/enums/boost/enums/ordinal/pred.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/ordinal/pred.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -0,0 +1,57 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/*!
+ \file
+ \brief
+ The header \c <boost/enums/pred.hpp> declares a class template \c meta::pred<> and
+ a function \c pred() returning the predecessor of the enumeration element.
+ */
+
+#ifndef BOOST_ENUMS_ORDINAL_PRED_HPP
+#define BOOST_ENUMS_ORDINAL_PRED_HPP
+
+#include <boost/enums/scoped/native_type.hpp>
+#include <boost/enums/ordinal/pos.hpp>
+#include <boost/enums/ordinal/val.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/assert.hpp>
+
+namespace boost
+{
+ namespace enums
+ {
+ namespace meta
+ {
+ //! meta-function that gets the predecessor of an enumeration element
+ //! Pre-condition: the position must be not 0
+ template <typename EC, typename enum_type<EC>::type V>
+ struct pred
+ {
+ BOOST_STATIC_ASSERT((pos<EC,V>::value!=0));
+ BOOST_STATIC_CONSTEXPR typename enum_type<EC>::type value =
+ val<EC,pos<EC,V>::value-1>::value;
+ };
+ }
+
+ //! Returns: the predecessor of the enumeration element
+ //! Throws: Invalid parameter if the position is 0
+ template <typename EC>
+ BOOST_CONSTEXPR EC pred(EC e)
+ {
+ BOOSt_ASSERT(pos(e)!=0);
+ return val<EC>(pos(e)-1);
+ }
+ }
+}
+
+#endif // BOOST_ENUMS_ORDINAL_PRED_HPP
Added: sandbox/enums/boost/enums/ordinal/size.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/ordinal/size.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -0,0 +1,51 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/*!
+ \file
+ \brief
+ The header \c <boost/enums/size.hpp> declares a class template \c meta::size<> and
+ a function \c size() returning the number of elements in the enumeration.
+ */
+
+#ifndef BOOST_ENUMS_ORDINAL_SIZE_HPP
+#define BOOST_ENUMS_ORDINAL_SIZE_HPP
+
+#include <boost/enums/scoped/native_type.hpp>
+
+
+namespace boost {
+ namespace enums {
+ namespace meta {
+ //! meta-function used to get the number of elements of an enumeration.
+
+ //! \note This meta-function must be specialized for each enumeration.
+ template <typename EC>
+#ifndef BOOST_ENUMS_DOXYGEN_INVOKED
+ struct size;
+#else
+ struct size
+ {
+ constexpr std::size_t value=<to be defined for each specialization>;
+ };
+#endif
+ }
+ template <typename EC>
+ std::size_t size()
+ {
+ return meta::size<EC>();
+ }
+
+ }
+}
+
+#endif // BOOST_ENUMS_ORDINAL_SIZE_HPP
Added: sandbox/enums/boost/enums/ordinal/succ.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/ordinal/succ.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -0,0 +1,61 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/*!
+ \file
+ \brief
+ The header \c <boost/enums/succ.hpp> declares a class template \c meta::succ<> and
+ a function \c succ() returning the predecessor of the enumeration element.
+ */
+
+#ifndef BOOST_ENUMS_ORDINAL_SUCC_HPP
+#define BOOST_ENUMS_ORDINAL_SUCC_HPP
+
+#include <boost/enums/scoped/native_type.hpp>
+#include <boost/enums/ordinal/pos.hpp>
+#include <boost/enums/ordinal/val.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/assert.hpp>
+
+namespace boost
+{
+ namespace enums
+ {
+ namespace meta
+ {
+ //! meta-function that gets the successor of an enumeration element
+ //! Pre-condition: the position must not be the last one
+ template <typename EC, typename enum_type<EC>::type V>
+ struct succ
+ {
+ BOOST_STATIC_ASSERT((pos<EC,V>::value!=(size<EC>::value-1)));
+ static const typename enum_type<EC>::type value =
+ val<EC,pos<EC,V>::value+1>::value;
+ };
+ }
+
+
+ //! enum succesor.
+
+ //! param e the enum literal.
+ //! \returns the successor of the enumeration element.
+ //! \throws Invalid parameter if the position is the last one.
+ template <typename EC>
+ EC succ(EC e)
+ {
+ BOOSt_ASSERT(pos(e)!=(meta::size<EC>::value-1));
+ return val<EC>(pos(e)+1);
+ }
+ }
+}
+
+#endif // BOOST_ENUMS_ORDINAL_SUCC_HPP
Added: sandbox/enums/boost/enums/ordinal/traits.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/ordinal/traits.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -0,0 +1,46 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/*!
+ \file
+ \brief
+ The header \c <boost/enums/ordinal/traits.hpp> declares a class template
+ \c meta::enum_traits<> which must be specialized for each enumeration including two static functions \c pos() and \c val().
+ */
+
+#ifndef BOOST_ENUMS_ORDINAL_TRAITS_HPP
+#define BOOST_ENUMS_ORDINAL_TRAITS_HPP
+
+namespace boost
+{
+ namespace enums
+ {
+ namespace meta
+ {
+ template <typename EC>
+#ifndef BOOST_ENUMS_DOXYGEN_INVOKED
+ struct enum_traits;
+#else
+ struct enum_traits
+ {
+ //! The specialization must define this function prototype
+ static std::size_t pos(EC e);
+ //! The specialization must define this function prototype
+ static EC val(std::size_t p);
+ };
+#endif
+
+ }
+ }
+}
+
+#endif // BOOST_ENUMS_ORDINAL_TRAITS_HPP
Added: sandbox/enums/boost/enums/ordinal/val.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/ordinal/val.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -0,0 +1,64 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/*!
+ \file
+ \brief
+ The header \c <boost/enums/val.hpp> declares a class template \c meta::val<> and
+ a function \c val() associating a position to an element of an enumeration.
+ */
+
+#ifndef BOOST_ENUMS_VALUE_HPP
+#define BOOST_ENUMS_VALUE_HPP
+
+#include <boost/enums/ordinal/traits.hpp>
+#include <boost/enums/ordinal/size.hpp>
+#include <boost/assert.hpp>
+#include <cstddef>
+
+namespace boost
+{
+ namespace enums
+ {
+ namespace meta
+ {
+ //! meta-function used to associate the position to an element of an enumeration.
+
+ //! \note This meta-function must be specialized for each position of the enumeration,
+ //! starting from 0 to the predecessor of the size of the enumeration .
+ template <typename EC, std::size_t I>
+#ifndef BOOST_ENUMS_DOXYGEN_INVOKED
+ struct val;
+#else
+ struct val
+ {
+ constexpr typename enum_type<EC>::type value=<to be defined for each specialization>;
+ };
+#endif
+
+ }
+ //! Value
+
+ //! \param p the position
+ //! \returns The enum class element associated to the position \c p.
+ //! \throws std::out_of_range if the position is out of range.
+ template <typename EC>
+ EC val(std::size_t p)
+ {
+ BOOST_ASSERT(p<(meta::size<EC>::value));
+ return meta::enum_traits<EC>::val(p);
+ }
+
+ }
+}
+
+#endif
Deleted: sandbox/enums/boost/enums/pos.hpp
==============================================================================
--- sandbox/enums/boost/enums/pos.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,68 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-/*!
- \file
- \brief
- The header \c <boost/enums/pos.hpp> declares a class template \c meta::pos<> and
- a function \c pos() associating the an element of an enumeration to
- its relative position.
- */
-
-#ifndef BOOST_ENUMS_POS_HPP
-#define BOOST_ENUMS_POS_HPP
-
-#include <boost/enums/enum_type.hpp>
-#include <boost/enums/enum_traits.hpp>
-#include <cstddef>
-
-
-namespace boost
-{
- namespace enums
- {
- namespace meta
- {
- //! meta-function used to associate the an element of an enumeration to
- //! its relative position.
-
- //! \note This meta-function must be specialized for each element of the enumeration.
- template <typename EC, typename enum_type<EC>::type V>
-#ifndef BOOST_ENUMS_DOXYGEN_INVOKED
- struct pos;
-#else
- struct pos
- {
- constexpr std::size_t value=<to be defined for each specialization>;
- };
-#endif
- }
-
-
- //! position of an enum literal \c e on the extension of the enumeration type \c EC.
-
- //! The \c enum_traits class must be specialized and contain a \c pos function
- //! that returns the relative position of its argument \c e.
-
- //! \param e the enum literal
- //! \returns the associated position
- //! \throws Nothing
- template <typename EC>
- std::size_t pos(EC e)
- {
- return meta::enum_traits<EC>::pos(e);
- }
-
- }
-}
-
-#endif
Deleted: sandbox/enums/boost/enums/pred.hpp
==============================================================================
--- sandbox/enums/boost/enums/pred.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,57 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-/*!
- \file
- \brief
- The header \c <boost/enums/pred.hpp> declares a class template \c meta::pred<> and
- a function \c pred() returning the predecessor of the enumeration element.
- */
-
-#ifndef BOOST_ENUMS_PRED_HPP
-#define BOOST_ENUMS_PRED_HPP
-
-#include <boost/enums/enum_type.hpp>
-#include <boost/enums/pos.hpp>
-#include <boost/enums/val.hpp>
-#include <boost/static_assert.hpp>
-#include <boost/assert.hpp>
-
-namespace boost
-{
- namespace enums
- {
- namespace meta
- {
- //! meta-function that gets the predecessor of an enumeration element
- //! Pre-condition: the position must be not 0
- template <typename EC, typename enum_type<EC>::type V>
- struct pred
- {
- BOOST_STATIC_ASSERT((pos<EC,V>::value!=0));
- BOOST_STATIC_CONSTEXPR typename enum_type<EC>::type value =
- val<EC,pos<EC,V>::value-1>::value;
- };
- }
-
- //! Returns: the predecessor of the enumeration element
- //! Throws: Invalid parameter if the position is 0
- template <typename EC>
- BOOST_CONSTEXPR EC pred(EC e)
- {
- BOOSt_ASSERT(pos(e)!=0);
- return val<EC>(pos(e)-1);
- }
- }
-}
-
-#endif
Added: sandbox/enums/boost/enums/scoped.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/scoped.hpp 2011-03-17 19:21:17 EDT (Thu, 17 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_ENUMS_SCOPED_HPP
+#define BOOST_ENUMS_SCOPED_HPP
+
+#include <boost/enums/scoped/emulation.hpp>
+#include <boost/enums/scoped/enum_class_cons.hpp>
+#include <boost/enums/scoped/enum_class_no_cons.hpp>
+#include <boost/enums/scoped/enum_type_cons.hpp>
+#include <boost/enums/scoped/enum_type_no_cons.hpp>
+#include <boost/enums/scoped/scoping_type.hpp>
+#include <boost/enums/scoped/native_type.hpp>
+#include <boost/enums/scoped/underlying_type.hpp>
+#include <boost/enums/scoped/default_value.hpp>
+#include <boost/enums/scoped/native_value.hpp>
+#include <boost/enums/scoped/underlying_value.hpp>
+
+
+#endif // BOOST_ENUMS_SCOPED_HPP
Added: sandbox/enums/boost/enums/scoped/default_value.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/scoped/default_value.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -0,0 +1,37 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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 BOOST_ENUMS_SCOPED_DEFAULT_VALUE_HPP
+#define BOOST_ENUMS_SCOPED_DEFAULT_VALUE_HPP
+
+#include <boost/config.hpp>
+
+namespace boost {
+ namespace enums {
+
+ //! builds a enum class with the default value.
+
+ //! \return the default value
+ template <typename EC>
+ inline EC default_value()
+ {
+#ifdef BOOST_NO_SCOPED_ENUMS
+ return EC::default_value();
+#else
+ return EC();
+#endif
+ }
+
+ }
+}
+
+#endif // BOOST_ENUMS_SCOPED_DEFAULT_VALUE_HPP
Added: sandbox/enums/boost/enums/scoped/emulation.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/scoped/emulation.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -0,0 +1,305 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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 BOOST_ENUMS_SCOPED_EMULATION_HPP
+#define BOOST_ENUMS_SCOPED_EMULATION_HPP
+
+#include <boost/enums/scoped/underlying_type.hpp>
+#include <boost/enums/scoped/native_type.hpp>
+#include <boost/enums/scoped/scoping_type.hpp>
+#include <boost/enums/scoped/default_value.hpp>
+#include <boost/enums/scoped/native_value.hpp>
+#include <boost/enums/scoped/underlying_value.hpp>
+#include <boost/conversion/convert_to.hpp>
+#include <boost/preprocessor/if.hpp>
+#include <boost/preprocessor/empty.hpp>
+#include <boost/enums/config.hpp>
+
+#ifndef BOOST_ENUMS_DOXYGEN_INVOKED
+
+#ifndef BOOST_NO_SCOPED_ENUMS
+ #define BOOST_ENUMS_DETAIL_BINARY_OPERATOR(EC, UT, OP) \
+ inline BOOST_CONSTEXPR bool operator OP(EC lhs, EC rhs) { \
+ return (UT)(lhs) \
+ OP \
+ (UT)(rhs); \
+ }
+
+#else // BOOST_NO_SCOPED_ENUMS
+
+ #define BOOST_ENUMS_DETAIL_BINARY_OPERATOR(EC, UT, OP) \
+ friend inline BOOST_CONSTEXPR bool operator OP(EC lhs, EC rhs) { \
+ return lhs.enum_value() OP rhs.enum_value(); \
+ } \
+ friend inline BOOST_CONSTEXPR bool operator OP(type lhs, EC rhs) { \
+ return lhs OP rhs.enum_value(); \
+ } \
+ friend inline BOOST_CONSTEXPR bool operator OP(EC lhs, type rhs) { \
+ return lhs.enum_value() OP rhs; \
+ }
+
+#endif // BOOST_NO_SCOPED_ENUMS
+
+#if !defined(BOOST_NO_SCOPED_ENUMS) && ! defined(BOOST_NO_SCOPED_ENUMS_COMPARE)
+
+ #define BOOST_ENUMS_DETAIL_COMPARAISON_OPERATORS(EC, UT)
+
+#else // !defined(BOOST_NO_SCOPED_ENUMS) && ! defined(BOOST_NO_SCOPED_ENUMS_COMPARE)
+
+ #define BOOST_ENUMS_DETAIL_COMPARAISON_OPERATORS(EC, UT) \
+ BOOST_ENUMS_DETAIL_BINARY_OPERATOR(EC, UT, ==) \
+ BOOST_ENUMS_DETAIL_BINARY_OPERATOR(EC, UT, !=) \
+ BOOST_ENUMS_DETAIL_BINARY_OPERATOR(EC, UT, <) \
+ BOOST_ENUMS_DETAIL_BINARY_OPERATOR(EC, UT, <=) \
+ BOOST_ENUMS_DETAIL_BINARY_OPERATOR(EC, UT, >) \
+ BOOST_ENUMS_DETAIL_BINARY_OPERATOR(EC, UT, >=)
+
+#endif // !defined(BOOST_NO_SCOPED_ENUMS) && ! defined(BOOST_NO_SCOPED_ENUMS_COMPARE)
+
+ #define BOOST_ENUMS_DETAIL_SCOPING_TYPE_SPEC(EC) \
+ namespace boost { \
+ namespace enums { \
+ template <> \
+ struct scoping_type<enum_type<EC>::type> \
+ { \
+ typedef EC type; \
+ }; \
+ } \
+ }
+
+#ifndef BOOST_NO_SCOPED_ENUMS
+
+ #ifdef BOOST_NO_UNDERLYING_TYPE
+
+ #define BOOST_ENUMS_DETAIL_UNDERLYING_TYPE_SPEC(EC, UT) \
+ namespace boost { \
+ namespace enums { \
+ template <> \
+ struct underlying_type<EC> \
+ { \
+ typedef UT type; \
+ }; \
+ } \
+ }
+
+ #else // BOOST_NO_UNDERLYING_TYPE
+
+ #define BOOST_ENUMS_DETAIL_UNDERLYING_TYPE_SPEC(EC, UT)
+
+ #endif // BOOST_NO_UNDERLYING_TYPE
+
+
+ #define BOOST_ENUMS_DETAIL_FRIEND_CONVERSIONS(EC, UT) \
+ inline EC convert_to(UT v \
+ , boost::dummy::type_tag<EC> const& \
+ ) \
+ { \
+ return EC(v); \
+ } \
+ inline EC convert_to(boost::enums::enum_type<EC>::type v \
+ , boost::dummy::type_tag<EC> const& \
+ ) \
+ { \
+ return v; \
+ } \
+ inline UT convert_to(EC v \
+ , boost::dummy::type_tag<UT> const& \
+ ) \
+ { \
+ return boost::enums::underlying_value(v); \
+ }
+#else
+
+#define BOOST_ENUMS_DETAIL_CONSTRUCTORS(EC, UT) \
+ EC() : val_(static_cast<underlying_type>(type())) { } \
+ EC(type v) : val_(static_cast<underlying_type>(v)) { } \
+ explicit EC(underlying_type v) : val_(v) { }
+
+
+#define BOOST_ENUMS_DETAIL_CONVERSIONS(EC, UT) \
+ operator type() { return type(val_); }
+
+
+#define BOOST_ENUMS_DETAIL_END_1(EC, UT) \
+ ; \
+ typedef UT underlying_type; \
+ private: \
+ underlying_type val_; \
+ public:
+
+
+
+#define BOOST_ENUMS_DETAIL_FRIEND_CONVERSIONS(EC, UT) \
+ inline friend EC convert_to(UT v \
+ , boost::dummy::type_tag<EC> const& \
+ ) \
+ { \
+ return EC::convert_to(v); \
+ } \
+ inline friend EC convert_to(boost::enums::enum_type<EC>::type v \
+ , boost::dummy::type_tag<EC> const& \
+ ) \
+ { \
+ return EC::convert_to(v); \
+ } \
+ inline friend UT convert_to(EC v \
+ , boost::dummy::type_tag<UT> const& \
+ ) \
+ { \
+ return boost::enums::underlying_value(v); \
+ } \
+ inline friend boost::enums::enum_type<EC>::type convert_to(EC v \
+ , boost::dummy::type_tag<boost::enums::enum_type<EC>::type> const& \
+ ) \
+ { \
+ return boost::enums::enum_value(v); \
+ }
+
+
+#define BOOST_ENUMS_DETAIL_END_2(EC, UT) \
+ EC& operator =(type rhs) { \
+ val_=static_cast<underlying_type>(rhs); \
+ return *this; \
+ } \
+ static EC default_value() \
+ { \
+ EC res; \
+ res.val_=static_cast<underlying_type>(EC::type()); \
+ return res; \
+ } \
+ static EC convert_to(underlying_type v) \
+ { \
+ EC res; \
+ res.val_=v; \
+ return res; \
+ } \
+ static EC convert_to(type v) \
+ { \
+ EC res; \
+ res.val_=static_cast<underlying_type>(v); \
+ return res; \
+ } \
+ type enum_value() const \
+ { \
+ return type(val_); \
+ } \
+ underlying_type underlying_value() const \
+ { \
+ return val_; \
+ } \
+ BOOST_ENUMS_DETAIL_FRIEND_CONVERSIONS(EC, UT)
+
+
+#endif
+#endif
+
+#ifndef BOOST_NO_SCOPED_ENUMS
+
+ #define BOOST_ENUM_CLASS_START(EC, UT) \
+ enum class EC : UT
+
+ #define BOOST_ENUM_TYPE_START(EC, UT) \
+ enum EC : UT
+
+ #define BOOST_ENUM_CLASS_END(EC, UT) \
+ ; \
+ BOOST_ENUMS_DETAIL_FRIEND_CONVERSIONS(EC, UT) \
+ BOOST_ENUMS_DETAIL_COMPARAISON_OPERATORS(EC, UT)
+
+ #define BOOST_ENUM_TYPE_END(EC, UT) \
+ ; \
+ BOOST_ENUMS_DETAIL_FRIEND_CONVERSIONS(EC, UT) \
+ BOOST_ENUMS_DETAIL_COMPARAISON_OPERATORS(EC, UT)
+
+ #define BOOST_ENUM_CLASS_NO_CONS_END(EC, UT) \
+ ; \
+ BOOST_ENUMS_DETAIL_FRIEND_CONVERSIONS(EC, UT) \
+ BOOST_ENUMS_DETAIL_COMPARAISON_OPERATORS(EC, UT)
+
+ #define BOOST_ENUM_TYPE_NO_CONS_END(EC, UT) \
+ ; \
+ BOOST_ENUMS_DETAIL_FRIEND_CONVERSIONS(EC, UT) \
+ BOOST_ENUMS_DETAIL_COMPARAISON_OPERATORS(EC, UT)
+
+ #define BOOST_ENUM_CLASS_CONS_END(EC, UT) \
+ ; \
+ BOOST_ENUMS_DETAIL_FRIEND_CONVERSIONS(EC, UT) \
+ BOOST_ENUMS_DETAIL_COMPARAISON_OPERATORS(EC, UT)
+
+ #define BOOST_ENUM_TYPE_CONS_END(EC, UT) \
+ ; \
+ BOOST_ENUMS_DETAIL_FRIEND_CONVERSIONS(EC, UT) \
+ BOOST_ENUMS_DETAIL_COMPARAISON_OPERATORS(EC, UT)
+
+ #define BOOST_ENUMS_SPECIALIZATIONS(EC, UT) \
+ BOOST_ENUMS_DETAIL_UNDERLYING_TYPE_SPEC(EC, UT)
+
+#else // BOOST_NO_SCOPED_ENUMS
+
+ #define BOOST_ENUM_CLASS_START(EC, UT) \
+ class EC \
+ { \
+ public: \
+ enum type
+
+ #define BOOST_ENUM_TYPE_START(EC, UT) \
+ class EC \
+ { \
+ public: \
+ enum type
+
+
+ #define BOOST_ENUM_CLASS_END(EC, UT) \
+ BOOST_ENUMS_DETAIL_END_1(EC, UT) \
+ BOOST_ENUMS_DETAIL_END_2(EC, UT) \
+ BOOST_ENUMS_DETAIL_COMPARAISON_OPERATORS(EC, UT) \
+ };
+
+
+ #define BOOST_ENUM_TYPE_END(EC, UT) \
+ BOOST_ENUMS_DETAIL_END_1(EC, UT) \
+ BOOST_ENUMS_DETAIL_CONVERSIONS(EC, UT) \
+ BOOST_ENUMS_DETAIL_END_2(EC, UT) \
+ };
+
+ #define BOOST_ENUM_CLASS_NO_CONS_END(EC, UT) \
+ BOOST_ENUMS_DETAIL_END_1(EC, UT) \
+ BOOST_ENUMS_DETAIL_END_2(EC, UT) \
+ BOOST_ENUMS_DETAIL_COMPARAISON_OPERATORS(EC, UT) \
+ };
+
+ #define BOOST_ENUM_TYPE_NO_CONS_END(EC, UT) \
+ BOOST_ENUMS_DETAIL_END_1(EC, UT) \
+ BOOST_ENUMS_DETAIL_CONVERSIONS(EC, UT) \
+ BOOST_ENUMS_DETAIL_END_2(EC, UT) \
+ };
+
+ #define BOOST_ENUM_CLASS_CONS_END(EC, UT) \
+ BOOST_ENUMS_DETAIL_END_1(EC, UT) \
+ BOOST_ENUMS_DETAIL_CONSTRUCTORS(EC, UT) \
+ BOOST_ENUMS_DETAIL_END_2(EC, UT) \
+ BOOST_ENUMS_DETAIL_COMPARAISON_OPERATORS(EC, UT) \
+ };
+
+ #define BOOST_ENUM_TYPE_CONS_END(EC, UT) \
+ BOOST_ENUMS_DETAIL_END_1(EC, UT) \
+ BOOST_ENUMS_DETAIL_CONSTRUCTORS(EC, UT) \
+ BOOST_ENUMS_DETAIL_CONVERSIONS(EC, UT) \
+ BOOST_ENUMS_DETAIL_END_2(EC, UT) \
+ };
+
+#define BOOST_ENUMS_SPECIALIZATIONS(EC, UT) \
+ BOOST_ENUMS_DETAIL_SCOPING_TYPE_SPEC(EC)
+
+
+#endif // BOOST_ENUMS_SCOPED_EMULATION_HPP
+#endif
Added: sandbox/enums/boost/enums/scoped/enum_class_cons.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/scoped/enum_class_cons.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -0,0 +1,231 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/*!
+ \file
+ \brief
+ The header \c <boost/enums/scoped/enum_class_cons.hpp> defines the declaration of enum_class_cons<> template class.
+ */
+
+#ifndef BOOST_ENUMS_SCOPED_ENUM_TYPE_CONS_HPP
+#define BOOST_ENUMS_SCOPED_ENUM_TYPE_CONS_HPP
+
+#include <boost/config.hpp>
+
+namespace boost
+{
+ namespace enums
+ {
+ //! scoped enum class with constructors
+
+ //! param @c ScopedEnum : Struct scoping the enum.\n
+ //! param @c UT : the underlaying storage type.\n
+ //! pre @c ScopedEnum must have a nested C++98 enum @c type.\n
+
+ template <typename ScopedEnum, typename UT=int>
+ class enum_class_cons : public ScopedEnum
+ {
+ public:
+ //! c++98 enum type
+ typedef typename ScopedEnum::type type;
+ //! underlying type
+ typedef UT underlying_type;
+ private:
+ underlying_type val_;
+ public:
+ //! default constructor
+ enum_class_cons()
+ : val_(static_cast<underlying_type>(type()))
+ {
+ }
+ //! explicit constructor from underlying type
+ explicit enum_class_cons(underlying_type v)
+ : val_(v)
+ {
+ }
+ //! constructor from enum type
+ enum_class_cons(type v)
+ : val_(static_cast<underlying_type>(v))
+ {
+ }
+ //! assignment
+ enum_class_cons& operator=(enum_class_cons rhs)
+ {
+ val_=rhs.val_;
+ return *this;
+ }
+ //! assignment from enum literals
+ enum_class_cons& operator=(type rhs)
+ {
+ val_=static_cast<underlying_type>(rhs);
+ return *this;
+ }
+ //! workaround when there are no constructors
+ static enum_class_cons default_value()
+ {
+ enum_class_cons res;
+ res.val_=static_cast<underlying_type>(type());
+ return res;
+ }
+
+ static enum_class_cons convert_to(underlying_type v)
+ {
+ enum_class_cons res;
+ res.val_=v;
+ return res;
+
+ }
+ static enum_class_cons convert_to(type v)
+ {
+ enum_class_cons res;
+ res.val_=static_cast<underlying_type>(v);
+ return res;
+ }
+ //! explicit conversion function to enum type
+ type enum_value() const
+ {
+ return type(val_);
+ }
+ //! explicit conversion function to underlying_type
+ underlying_type underlying_value() const
+ {
+ return val_;
+ }
+
+ //! equal operator
+ friend bool operator==(enum_class_cons lhs, enum_class_cons rhs)
+ {
+ return lhs.val_ == rhs.val_;
+ }
+ //! equal operator
+ friend bool operator==(type lhs, enum_class_cons rhs)
+ {
+ return lhs == rhs.val_;
+ }
+ //! equal operator
+ friend bool operator==(enum_class_cons lhs, type rhs)
+ {
+ return lhs.val_ == rhs;
+ }
+ //! not_equal operator
+ friend bool operator!=(enum_class_cons lhs, enum_class_cons rhs)
+ {
+ return lhs.val_ != rhs.val_;
+ }
+ //! not_equal operator
+ friend bool operator!=(type lhs, enum_class_cons rhs)
+ {
+ return lhs != rhs.val_;
+ }
+ //! not_equal operator
+ friend bool operator!=(enum_class_cons lhs, type rhs)
+ {
+ return lhs.val_ != rhs;
+ }
+ //! less_equal operator
+ friend bool operator<=(enum_class_cons lhs, enum_class_cons rhs)
+ {
+ return lhs.val_ <= rhs.val_;
+ }
+ //! less_equal operator
+ friend bool operator<=(type lhs, enum_class_cons rhs)
+ {
+ return lhs <= rhs.val_;
+ }
+ //! less_equal operator
+ friend bool operator<=(enum_class_cons lhs, type rhs)
+ {
+ return lhs.val_ <= rhs;
+ }
+ //! less operator
+ friend bool operator<(enum_class_cons lhs, enum_class_cons rhs)
+ {
+ return lhs.val_ < rhs.val_;
+ }
+ //! less operator
+ friend bool operator<(type lhs, enum_class_cons rhs)
+ {
+ return lhs < rhs.val_;
+ }
+ //! less operator
+ friend bool operator<(enum_class_cons lhs, type rhs)
+ {
+ return lhs.val_ < rhs;
+ }
+ //! greater_equal operator
+ friend bool operator>=(enum_class_cons lhs, enum_class_cons rhs)
+ {
+ return lhs.val_ >= rhs.val_;
+ }
+ //! greater_equal operator
+ friend bool operator>=(type lhs, enum_class_cons rhs)
+ {
+ return lhs >= rhs.val_;
+ }
+ //! greater_equal operator
+ friend bool operator>=(enum_class_cons lhs, type rhs)
+ {
+ return lhs.val_ >= rhs;
+ }
+ //! greater operator
+ friend bool operator>(enum_class_cons lhs, enum_class_cons rhs)
+ {
+ return lhs.val_ > rhs.val_;
+ }
+ //! greater operator
+ friend bool operator>(type lhs, enum_class_cons rhs)
+ {
+ return lhs > rhs.val_;
+ }
+ //! greater operator
+ friend bool operator>(enum_class_cons lhs, type rhs)
+ {
+ return lhs.val_ > rhs;
+ }
+#if 0
+ //! conversions from underlying_type to enum_type_cons following the Boost.Conversion protocol
+ friend enum_class_cons convert_to(underlying_type v,
+ boost::dummy::type_tag<enum_class_cons> const&)
+ {
+ enum_class_cons res;
+ res.val_=v;
+ return res;
+
+ }
+
+ //! friend conversions from type to enum_type_cons following the Boost.Conversion protocol
+ friend enum_class_cons convert_to(type v,
+ boost::dummy::type_tag<enum_class_cons> const&)
+ {
+ enum_class_cons res;
+ res.val_=static_cast<underlying_type>(v);
+ return res;
+ }
+#endif
+ //! conversions from enum_type_cons to underlying_type following the Boost.Conversion protocol
+ friend underlying_type convert_to(enum_class_cons v,
+ boost::dummy::type_tag<underlying_type> const&)
+ {
+ return boost::enums::underlying_value(v);
+ }
+
+ //! conversions from enum_type_cons to type following the Boost.Conversion protocol
+ friend type convert_to(enum_class_cons v,
+ boost::dummy::type_tag<type> const&)
+ {
+ return boost::enums::enum_value(v);
+ }
+ };
+ }
+}
+
+#endif // BOOST_ENUMS_SCOPED_ENUM_TYPE_MIXIN_HPP
Added: sandbox/enums/boost/enums/scoped/enum_class_no_cons.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/scoped/enum_class_no_cons.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -0,0 +1,219 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/*!
+ \file
+ \brief
+ The header \c <boost/enums/scoped/enum_class_no_cons.hpp> defines the declaration of enum_class_no_cons<> template class.
+ */
+
+#ifndef BOOST_ENUMS_SCOPED_ENUM_TYPE_NO_CONS_HPP
+#define BOOST_ENUMS_SCOPED_ENUM_TYPE_NO_CONS_HPP
+
+#include <boost/config.hpp>
+
+namespace boost
+{
+ namespace enums
+ {
+ //! scoped enum class without constructors
+
+ //! param @c ScopedEnum : Struct scoping the enum.\n
+ //! param @c UT : the underlaying storage type.\n
+ //! pre @c ScopedEnum must have a nested C++98 enum @c type.\n
+ template <typename ScopedEnum, typename UT=int>
+ class enum_class_no_cons : public ScopedEnum
+ {
+ public:
+ //! c++98 enum type
+ typedef typename ScopedEnum::type type;
+ //! underlying type
+ typedef UT underlying_type;
+ private:
+ underlying_type val_;
+ public:
+ //! assignment
+ enum_class_no_cons& operator=(enum_class_no_cons rhs)
+ {
+ val_=rhs.val_;
+ return *this;
+ }
+
+ //! assignment from enum literals
+ enum_class_no_cons& operator=(type rhs)
+ {
+ val_=static_cast<underlying_type>(rhs);
+ return *this;
+ }
+
+ //! workaround when there are no constructors
+ static enum_class_no_cons default_value()
+ {
+ enum_class_no_cons res;
+ res.val_=static_cast<underlying_type>(type());
+ return res;
+ }
+
+ static enum_class_no_cons convert_to(underlying_type v)
+ {
+ enum_class_no_cons res;
+ res.val_=v;
+ return res;
+
+ }
+
+ static enum_class_no_cons convert_to(type v)
+ {
+ enum_class_no_cons res;
+ res.val_=static_cast<underlying_type>(v);
+ return res;
+ }
+
+ //! explicit conversion function to enum type
+ type enum_value() const
+ {
+ return type(val_);
+ }
+
+ //! explicit conversion function to underlying_type
+ underlying_type underlying_value() const
+ {
+ return val_;
+ }
+
+ //! equal operator
+ friend bool operator==(enum_class_no_cons lhs, enum_class_no_cons rhs)
+ {
+ return lhs.val_ == rhs.val_;
+ }
+ //! equal operator
+ friend bool operator==(type lhs, enum_class_no_cons rhs)
+ {
+ return lhs == rhs.val_;
+ }
+ //! equal operator
+ friend bool operator==(enum_class_no_cons lhs, type rhs)
+ {
+ return lhs.val_ == rhs;
+ }
+ //! not_equal operator
+ friend bool operator!=(enum_class_no_cons lhs, enum_class_no_cons rhs)
+ {
+ return lhs.val_ != rhs.val_;
+ }
+ //! not_equal operator
+ friend bool operator!=(type lhs, enum_class_no_cons rhs)
+ {
+ return lhs != rhs.val_;
+ }
+ //! not_equal operator
+ friend bool operator!=(enum_class_no_cons lhs, type rhs)
+ {
+ return lhs.val_ != rhs;
+ }
+ //! less_equal operator
+ friend bool operator<=(enum_class_no_cons lhs, enum_class_no_cons rhs)
+ {
+ return lhs.val_ <= rhs.val_;
+ }
+ //! less_equal operator
+ friend bool operator<=(type lhs, enum_class_no_cons rhs)
+ {
+ return lhs <= rhs.val_;
+ }
+ //! less_equal operator
+ friend bool operator<=(enum_class_no_cons lhs, type rhs)
+ {
+ return lhs.val_ <= rhs;
+ }
+ //! less operator
+ friend bool operator<(enum_class_no_cons lhs, enum_class_no_cons rhs)
+ {
+ return lhs.val_ < rhs.val_;
+ }
+ //! less operator
+ friend bool operator<(type lhs, enum_class_no_cons rhs)
+ {
+ return lhs < rhs.val_;
+ }
+ //! less operator
+ friend bool operator<(enum_class_no_cons lhs, type rhs)
+ {
+ return lhs.val_ < rhs;
+ }
+ //! greater_equal operator
+ friend bool operator>=(enum_class_no_cons lhs, enum_class_no_cons rhs)
+ {
+ return lhs.val_ >= rhs.val_;
+ }
+ //! greater_equal operator
+ friend bool operator>=(type lhs, enum_class_no_cons rhs)
+ {
+ return lhs >= rhs.val_;
+ }
+ //! greater_equal operator
+ friend bool operator>=(enum_class_no_cons lhs, type rhs)
+ {
+ return lhs.val_ >= rhs;
+ }
+ //! greater operator
+ friend bool operator>(enum_class_no_cons lhs, enum_class_no_cons rhs)
+ {
+ return lhs.val_ > rhs.val_;
+ }
+ //! greater operator
+ friend bool operator>(type lhs, enum_class_no_cons rhs)
+ {
+ return lhs > rhs.val_;
+ }
+ //! greater operator
+ friend bool operator>(enum_class_no_cons lhs, type rhs)
+ {
+ return lhs.val_ > rhs;
+ }
+
+ //! conversions from underlying_type to enum_type_cons following the Boost.Conversion protocol
+ friend enum_class_no_cons convert_to(underlying_type v,
+ boost::dummy::type_tag<enum_class_no_cons> const&)
+ {
+ enum_class_no_cons res;
+ res.val_=v;
+ return res;
+ }
+
+ //! friend conversions from type to enum_type_cons following the Boost.Conversion protocol
+ friend enum_class_no_cons convert_to(type v,
+ boost::dummy::type_tag<enum_class_no_cons> const&)
+ {
+ enum_class_no_cons res;
+ res.val_=static_cast<underlying_type>(v);
+ return res;
+ }
+
+ //! conversions from enum_type_cons to underlying_type following the Boost.Conversion protocol
+ friend underlying_type convert_to(enum_class_no_cons v,
+ boost::dummy::type_tag<underlying_type> const&)
+ {
+ return boost::enums::underlying_value(v);
+ }
+
+ //! conversions from enum_type_cons to type following the Boost.Conversion protocol
+ friend type convert_to(enum_class_no_cons v,
+ boost::dummy::type_tag<type> const&)
+ {
+ return boost::enums::enum_value(v);
+ }
+ };
+ }
+}
+
+#endif // BOOST_ENUMS_SCOPED_ENUM_TYPE_NO_CONS_HPP
Added: sandbox/enums/boost/enums/scoped/enum_type_cons.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/scoped/enum_type_cons.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -0,0 +1,250 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/*!
+ \file
+ \brief
+ The header \c <boost/enums/scoped/enum_type_cons.hpp> defines the declaration of enum_type_cons<> template class.
+ */
+
+#ifndef BOOST_ENUMS_SCOPED_ENUM_TYPE_CONS_HPP
+#define BOOST_ENUMS_SCOPED_ENUM_TYPE_CONS_HPP
+
+#include <boost/config.hpp>
+
+namespace boost
+{
+ namespace enums
+ {
+ //! scoped enum type with constructors
+
+ //! param @c ScopedEnum : Struct scoping the enum.\n
+ //! param @c UT : the underlaying storage type.\n
+ //! pre @c ScopedEnum must have a nested C++98 enum @c type.\n
+ template <typename ScopedEnum, typename UT=int>
+ class enum_type_cons : public ScopedEnum
+ {
+ public:
+ //! c++98 enum type
+ typedef typename ScopedEnum::type type;
+ //! underlying type
+ typedef UT underlying_type;
+ private:
+ underlying_type val_;
+ public:
+ //! default constructor
+ enum_type_cons()
+ : val_(static_cast<underlying_type>(type()))
+ {
+ }
+
+ //! explicit constructor from underlying type
+ explicit enum_type_cons(underlying_type v)
+ : val_(v)
+ {
+ }
+
+ //! constructor from enum type
+ enum_type_cons(type v)
+ : val_(static_cast<underlying_type>(v))
+ {
+ }
+
+#if 0
+ //! implicit conversion to underlying_type
+ operator underlying_type()
+ {
+ return val_;
+ }
+#endif
+ //! implicit conversion to enum type
+ operator type()
+ {
+ return type(val_);
+ }
+
+ //! assignment
+ enum_type_cons& operator=(enum_type_cons rhs)
+ {
+ val_=rhs.val_;
+ return *this;
+ }
+ //! assignment from enum literals
+ enum_type_cons& operator=(type rhs)
+ {
+ val_=static_cast<underlying_type>(rhs);
+ return *this;
+ }
+ //! workaround in case there are no constructors
+ static enum_type_cons default_value()
+ {
+ enum_type_cons res;
+ res.val_=static_cast<underlying_type>(type());
+ return res;
+ }
+
+ static enum_type_cons convert_to(underlying_type v)
+ {
+ enum_type_cons res;
+ res.val_=v;
+ return res;
+
+ }
+
+ static enum_type_cons convert_to(type v)
+ {
+ enum_type_cons res;
+ res.val_=static_cast<underlying_type>(v);
+ return res;
+ }
+
+ //! explicit conversion function to enum type
+ type enum_value() const
+ {
+ return type(val_);
+ }
+
+ //! explicit conversion function to underlying_type
+ underlying_type underlying_value() const
+ {
+ return val_;
+ }
+#if 0
+ //! equal operator
+ friend bool operator==(enum_type_cons lhs, enum_type_cons rhs)
+ {
+ return lhs.val_ == rhs.val_;
+ }
+ //! equal operator
+ friend bool operator==(type lhs, enum_type_cons rhs)
+ {
+ return lhs == rhs.val_;
+ }
+
+ //! equal operator
+ friend bool operator==(enum_type_cons lhs, type rhs)
+ {
+ return lhs.val_ == rhs;
+ }
+ //! not_equal operator
+ friend bool operator!=(enum_type_cons lhs, enum_type_cons rhs)
+ {
+ return lhs.val_ != rhs.val_;
+ }
+ //! not_equal operator
+ friend bool operator!=(type lhs, enum_type_cons rhs)
+ {
+ return lhs != rhs.val_;
+ }
+ //! not_equal operator
+ friend bool operator!=(enum_type_cons lhs, type rhs)
+ {
+ return lhs.val_ != rhs;
+ }
+ //! less_equal operator
+ friend bool operator<=(enum_type_cons lhs, enum_type_cons rhs)
+ {
+ return lhs.val_ <= rhs.val_;
+ }
+ //! less_equal operator
+ friend bool operator<=(type lhs, enum_type_cons rhs)
+ {
+ return lhs <= rhs.val_;
+ }
+ //! less_equal operator
+ friend bool operator<=(enum_type_cons lhs, type rhs)
+ {
+ return lhs.val_ <= rhs;
+ }
+ //! less operator
+ friend bool operator<(enum_type_cons lhs, enum_type_cons rhs)
+ {
+ return lhs.val_ < rhs.val_;
+ }
+ //! less operator
+ friend bool operator<(type lhs, enum_type_cons rhs)
+ {
+ return lhs < rhs.val_;
+ }
+ //! less operator
+ friend bool operator<(enum_type_cons lhs, type rhs)
+ {
+ return lhs.val_ < rhs;
+ }
+ //! greater_equal operator
+ friend bool operator>=(enum_type_cons lhs, enum_type_cons rhs)
+ {
+ return lhs.val_ >= rhs.val_;
+ }
+ //! greater_equal operator
+ friend bool operator>=(type lhs, enum_type_cons rhs)
+ {
+ return lhs >= rhs.val_;
+ }
+ //! greater_equal operator
+ friend bool operator>=(enum_type_cons lhs, type rhs)
+ {
+ return lhs.val_ >= rhs;
+ }
+ //! greater operator
+ friend bool operator>(enum_type_cons lhs, enum_type_cons rhs)
+ {
+ return lhs.val_ > rhs.val_;
+ }
+ //! greater operator
+ friend bool operator>(type lhs, enum_type_cons rhs)
+ {
+ return lhs > rhs.val_;
+ }
+ //! greater operator
+ friend bool operator>(enum_type_cons lhs, type rhs)
+ {
+ return lhs.val_ > rhs;
+ }
+#endif
+#if 0
+ //! conversions from underlying_type to enum_type_cons following the Boost.Conversion protocol
+ friend enum_type_cons convert_to(underlying_type v,
+ boost::dummy::type_tag<enum_type_cons> const&)
+ {
+ enum_type_cons res;
+ res.val_=v;
+ return res;
+
+ }
+
+ //! friend conversions from type to enum_type_cons following the Boost.Conversion protocol
+ friend enum_type_cons convert_to(type v,
+ boost::dummy::type_tag<enum_type_cons> const&)
+ {
+ enum_type_cons res;
+ res.val_=static_cast<underlying_type>(v);
+ return res;
+ }
+#endif
+ //! conversions from enum_type_cons to underlying_type following the Boost.Conversion protocol
+ friend underlying_type convert_to(enum_type_cons v,
+ boost::dummy::type_tag<underlying_type> const&)
+ {
+ return boost::enums::underlying_value(v);
+ }
+ //! conversions from enum_type_cons to type following the Boost.Conversion protocol
+ friend type convert_to(enum_type_cons v,
+ boost::dummy::type_tag<type> const&)
+ {
+ return boost::enums::enum_value(v);
+ }
+ };
+ }
+}
+
+#endif // BOOST_ENUMS_SCOPED_ENUM_TYPE_CONS_HPP
Added: sandbox/enums/boost/enums/scoped/enum_type_no_cons.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/scoped/enum_type_no_cons.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -0,0 +1,234 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/*!
+ \file
+ \brief
+ The header \c <boost/enums/scoped/enum_type_no_cons.hpp> defines the declaration of enum_type_no_cons<> template class.
+ */
+
+#ifndef BOOST_ENUMS_SCOPED_ENUM_TYPE_NO_CONS_HPP
+#define BOOST_ENUMS_SCOPED_ENUM_TYPE_NO_CONS_HPP
+
+#include <boost/config.hpp>
+
+namespace boost
+{
+ namespace enums
+ {
+ //! scoped enum type without constructors
+
+ //! param @c ScopedEnum : Struct scoping the enum.\n
+ //! param @c UT : the underlaying storage type.\n
+ //! pre @c ScopedEnum must have a nested C++98 enum @c type.\n
+ template <typename ScopedEnum, typename UT=int>
+ class enum_type_no_cons : public ScopedEnum
+ {
+ public:
+ //! c++98 enum type
+ typedef typename ScopedEnum::type type;
+ //! underlying type
+ typedef UT underlying_type;
+ private:
+ underlying_type val_;
+ public:
+
+#if 0
+ //! implicit conversion to underlying_type
+ operator underlying_type()
+ {
+ return val_;
+ }
+#endif
+
+ //! implicit conversion to enum type
+ operator type()
+ {
+ return type(val_);
+ }
+
+ //! assignment
+ enum_type_no_cons& operator=(enum_type_no_cons rhs)
+ {
+ val_=rhs.val_;
+ return *this;
+ }
+
+ //! assignment from enum literals
+ enum_type_no_cons& operator=(type rhs)
+ {
+ val_=static_cast<underlying_type>(rhs);
+ return *this;
+ }
+
+ //! workaround in case there are no constructors
+ static enum_type_no_cons default_value()
+ {
+ enum_type_no_cons res;
+ res.val_=static_cast<underlying_type>(type());
+ return res;
+ }
+
+ static enum_type_no_cons convert_to(underlying_type v)
+ {
+ enum_type_no_cons res;
+ res.val_=v;
+ return res;
+
+ }
+
+ static enum_type_no_cons convert_to(type v)
+ {
+ enum_type_no_cons res;
+ res.val_=static_cast<underlying_type>(v);
+ return res;
+ }
+ //! explicit conversion function to enum type
+ type enum_value() const
+ {
+ return type(val_);
+ }
+ //! explicit conversion function to underlying_type
+ underlying_type underlying_value() const
+ {
+ return val_;
+ }
+#if 0
+
+ //! equal operator
+ friend bool operator==(enum_type_no_cons lhs, enum_type_no_cons rhs)
+ {
+ return lhs.val_ == rhs.val_;
+ }
+ //! equal operator
+ friend bool operator==(type lhs, enum_type_no_cons rhs)
+ {
+ return lhs == rhs.val_;
+ }
+ //! equal operator
+ friend bool operator==(enum_type_no_cons lhs, type rhs)
+ {
+ return lhs.val_ == rhs;
+ }
+ //! not_equal operator
+ friend bool operator!=(enum_type_no_cons lhs, enum_type_no_cons rhs)
+ {
+ return lhs.val_ != rhs.val_;
+ }
+ //! not_equal operator
+ friend bool operator!=(type lhs, enum_type_no_cons rhs)
+ {
+ return lhs != rhs.val_;
+ }
+ //! not_equal operator
+ friend bool operator!=(enum_type_no_cons lhs, type rhs)
+ {
+ return lhs.val_ != rhs;
+ }
+ //! less_equal operator
+ friend bool operator<=(enum_type_no_cons lhs, enum_type_no_cons rhs)
+ {
+ return lhs.val_ <= rhs.val_;
+ }
+ //! less_equal operator
+ friend bool operator<=(type lhs, enum_type_no_cons rhs)
+ {
+ return lhs <= rhs.val_;
+ }
+ //! less_equal operator
+ friend bool operator<=(enum_type_no_cons lhs, type rhs)
+ {
+ return lhs.val_ <= rhs;
+ }
+ //! less operator
+ friend bool operator<(enum_type_no_cons lhs, enum_type_no_cons rhs)
+ {
+ return lhs.val_ < rhs.val_;
+ }
+ //! less operator
+ friend bool operator<(type lhs, enum_type_no_cons rhs)
+ {
+ return lhs < rhs.val_;
+ }
+ //! less operator
+ friend bool operator<(enum_type_no_cons lhs, type rhs)
+ {
+ return lhs.val_ < rhs;
+ }
+ //! greater_equal operator
+ friend bool operator>=(enum_type_no_cons lhs, enum_type_no_cons rhs)
+ {
+ return lhs.val_ >= rhs.val_;
+ }
+ //! greater_equal operator
+ friend bool operator>=(type lhs, enum_type_no_cons rhs)
+ {
+ return lhs >= rhs.val_;
+ }
+ //! greater_equal operator
+ friend bool operator>=(enum_type_no_cons lhs, type rhs)
+ {
+ return lhs.val_ >= rhs;
+ }
+ //! greater operator
+ friend bool operator>(enum_type_no_cons lhs, enum_type_no_cons rhs)
+ {
+ return lhs.val_ > rhs.val_;
+ }
+ //! greater operator
+ friend bool operator>(type lhs, enum_type_no_cons rhs)
+ {
+ return lhs > rhs.val_;
+ }
+ //! greater operator
+ friend bool operator>(enum_type_no_cons lhs, type rhs)
+ {
+ return lhs.val_ > rhs;
+ }
+#endif
+
+ //! conversions from underlying_type to enum_type_cons following the Boost.Conversion protocol
+ friend enum_type_no_cons convert_to(underlying_type v,
+ boost::dummy::type_tag<enum_type_no_cons> const&)
+ {
+ enum_type_no_cons res;
+ res.val_=v;
+ return res;
+ }
+
+ //! friend conversions from type to enum_type_cons following the Boost.Conversion protocol
+ friend enum_type_no_cons convert_to(type v,
+ boost::dummy::type_tag<enum_type_no_cons> const&)
+ {
+ enum_type_no_cons res;
+ res.val_=static_cast<underlying_type>(v);
+ return res;
+ }
+
+ //! conversions from enum_type_cons to underlying_type following the Boost.Conversion protocol
+ friend underlying_type convert_to(enum_type_no_cons v,
+ boost::dummy::type_tag<underlying_type> const&)
+ {
+ return boost::enums::underlying_value(v);
+ }
+
+ //! conversions from enum_type_cons to type following the Boost.Conversion protocol
+ friend type convert_to(enum_type_no_cons v,
+ boost::dummy::type_tag<type> const&)
+ {
+ return boost::enums::enum_value(v);
+ }
+ };
+ }
+}
+
+#endif // BOOST_ENUMS_SCOPED_ENUM_TYPE_MIXIN_HPP
Added: sandbox/enums/boost/enums/scoped/native_type.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/scoped/native_type.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -0,0 +1,40 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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 BOOST_ENUMS_SCOPED_NATIVE_TYPE_HPP
+#define BOOST_ENUMS_SCOPED_NATIVE_TYPE_HPP
+
+#include <boost/config.hpp>
+
+namespace boost
+{
+ namespace enums
+ {
+ //! meta-function to get the native enum type associated to an enum class
+ //! or its emulation
+ template <typename EC>
+ struct enum_type
+ {
+#ifndef BOOST_ENUMS_DOXYGEN_INVOKED
+ #ifdef BOOST_NO_SCOPED_ENUMS
+ typedef typename EC::type type;
+ #else
+ typedef EC type;
+ #endif
+#else
+ typedef <see below> type;
+#endif
+ };
+ }
+}
+
+#endif // BOOST_ENUMS_SCOPED_NATIVE_TYPE_HPP
Added: sandbox/enums/boost/enums/scoped/native_value.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/scoped/native_value.hpp 2011-03-17 19:21:17 EDT (Thu, 17 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_ENUMS_SCOPED_NATIVE_VALUE_HPP
+#define BOOST_ENUMS_SCOPED_NATIVE_VALUE_HPP
+
+#include <boost/config.hpp>
+#include <boost/enums/scoped/native_type.hpp>
+
+namespace boost {
+ namespace enums {
+
+ template <typename EC>
+ inline
+ typename enum_type<EC>::type enum_value(EC e)
+ {
+#ifdef BOOST_NO_SCOPED_ENUMS
+ return e.enum_value();
+#else
+ return e;
+#endif
+ }
+ }
+}
+
+#endif // BOOST_ENUMS_SCOPED_NATIVE_VALUE_HPP
Added: sandbox/enums/boost/enums/scoped/scoping_type.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/scoped/scoping_type.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -0,0 +1,42 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/*!
+ \file
+ \brief
+ The header \c <boost/enums/scoped/scoping_type.hpp> defines the declaration of scoping_type<> meta-function.
+ */
+
+#ifndef BOOST_ENUMS_SCOPED_SCOPING_TYPE_HPP
+#define BOOST_ENUMS_SCOPED_SCOPING_TYPE_HPP
+
+#include <boost/config.hpp>
+
+namespace boost
+{
+ namespace enums
+ {
+ /*! meta-function used to get the wrapping class of an enum when emulation
+ is used or the enum class itself when available.
+ This meta-function must be specialized for each enum class.
+ */
+ template <typename EC_type>
+ struct scoping_type
+ {
+ //! Depending on whethere the compiler supports scoped enums or nor the nested type must be the same type or the emulated one.
+ //! By default this metafunction defines it as if scoped enums where supported so the specialization will be needed only when emulation is needed.
+ typedef EC_type type;
+ };
+ }
+}
+
+#endif // BOOST_ENUMS_SCOPED_SCOPING_TYPE_HPP
Added: sandbox/enums/boost/enums/scoped/underlying_type.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/scoped/underlying_type.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
@@ -0,0 +1,52 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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 BOOST_ENUMS_SCOPED_UNDERLYING_TYPE_HPP
+#define BOOST_ENUMS_SCOPED_UNDERLYING_TYPE_HPP
+
+#include <boost/enums/config.hpp>
+#ifndef BOOST_NO_UNDERLYING_TYPE
+ #include <type_traits>
+#endif
+
+namespace boost
+{
+ namespace enums
+ {
+ //! underlying type metafunction
+
+ //! \c EC must be an enum type or the emulation of a scoped enum.\n\n
+
+ template <typename EC>
+ struct underlying_type
+ {
+#ifdef BOOST_ENUMS_DOXYGEN_INVOKED
+ //! The member typedef \c type name the underlying type of \c T.
+ //! When scoped enums are emulated it is defined as \c typename \c EC::underlying_type.
+ //! Otherwise is defined as \c std::underlying_type<EC>::type.
+ //! This meta-function must be specialized for the compilers providing scoped enums
+ //! but don't providing the \c std::underlying_type meta-function.
+ typedef see_below type;
+#else
+ #ifdef BOOST_NO_SCOPED_ENUMS
+ typedef typename EC::underlying_type type;
+ #else
+ #ifndef BOOST_NO_UNDERLYING_TYPE
+ typedef std::underlying_type<EC>::type type;
+ #endif
+ #endif
+#endif
+ };
+ }
+}
+
+#endif // BOOST_ENUMS_SCOPED_UNDERLYING_TYPE_HPP
Added: sandbox/enums/boost/enums/scoped/underlying_value.hpp
==============================================================================
--- (empty file)
+++ sandbox/enums/boost/enums/scoped/underlying_value.hpp 2011-03-17 19:21:17 EDT (Thu, 17 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_ENUMS_SCOPED_UNDERLYING_VALUE_HPP
+#define BOOST_ENUMS_SCOPED_UNDERLYING_VALUE_HPP
+
+#include <boost/config.hpp>
+#include <boost/enums/scoped/native_type.hpp>
+
+namespace boost {
+ namespace enums {
+
+ template <typename EC>
+ inline
+ typename underlying_type<EC>::type
+ underlying_value(EC e)
+ {
+#ifdef BOOST_NO_SCOPED_ENUMS
+ return e.underlying_value();
+#else
+ return static_cast<typename underlying_type<EC>::type>(e);
+#endif
+ }
+ }
+}
+
+#endif // BOOST_ENUMS_SCOPED_UNDERLYING_VALUE_HPP
Deleted: sandbox/enums/boost/enums/scoping_type.hpp
==============================================================================
--- sandbox/enums/boost/enums/scoping_type.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,42 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-/*!
- \file
- \brief
- The header \c <boost/enums/scoping_type.hpp> defines the declaration of scoping_type<> meta-function.
- */
-
-#ifndef BOOST_ENUMS_SCOPING_TYPE_HPP
-#define BOOST_ENUMS_SCOPING_TYPE_HPP
-
-#include <boost/config.hpp>
-
-namespace boost
-{
- namespace enums
- {
- /*! meta-function used to get the wrapping class of an enum when emulation
- is used or the enum class itself when available.
- This meta-function must be specialized for each enum class.
- */
- template <typename EC_type>
- struct scoping_type
- {
- //! Depending on whethere the compiler supports scoped enums or nor the nested type must be the same type or the emulated one.
- //! By default this metafunction defines it as if scoped enums where supported so the specialization will be needed only when emulation is needed.
- typedef EC_type type;
- };
- }
-}
-
-#endif // BOOST_ENUMS_SCOPING_TYPE_HPP
Deleted: sandbox/enums/boost/enums/size.hpp
==============================================================================
--- sandbox/enums/boost/enums/size.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,51 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-/*!
- \file
- \brief
- The header \c <boost/enums/size.hpp> declares a class template \c meta::size<> and
- a function \c size() returning the number of elements in the enumeration.
- */
-
-#ifndef BOOST_ENUMS_SIZE_HPP
-#define BOOST_ENUMS_SIZE_HPP
-
-#include <boost/enums/enum_type.hpp>
-
-
-namespace boost {
- namespace enums {
- namespace meta {
- //! meta-function used to get the number of elements of an enumeration.
-
- //! \note This meta-function must be specialized for each enumeration.
- template <typename EC>
-#ifndef BOOST_ENUMS_DOXYGEN_INVOKED
- struct size;
-#else
- struct size
- {
- constexpr std::size_t value=<to be defined for each specialization>;
- };
-#endif
- }
- template <typename EC>
- std::size_t size()
- {
- return meta::size<EC>();
- }
-
- }
-}
-
-#endif
Deleted: sandbox/enums/boost/enums/succ.hpp
==============================================================================
--- sandbox/enums/boost/enums/succ.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,61 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-/*!
- \file
- \brief
- The header \c <boost/enums/succ.hpp> declares a class template \c meta::succ<> and
- a function \c succ() returning the predecessor of the enumeration element.
- */
-
-#ifndef BOOST_ENUMS_SUCC_HPP
-#define BOOST_ENUMS_SUCC_HPP
-
-#include <boost/enums/enum_type.hpp>
-#include <boost/enums/pos.hpp>
-#include <boost/enums/val.hpp>
-#include <boost/static_assert.hpp>
-#include <boost/assert.hpp>
-
-namespace boost
-{
- namespace enums
- {
- namespace meta
- {
- //! meta-function that gets the successor of an enumeration element
- //! Pre-condition: the position must not be the last one
- template <typename EC, typename enum_type<EC>::type V>
- struct succ
- {
- BOOST_STATIC_ASSERT((pos<EC,V>::value!=(size<EC>::value-1)));
- static const typename enum_type<EC>::type value =
- val<EC,pos<EC,V>::value+1>::value;
- };
- }
-
-
- //! enum succesor.
-
- //! param e the enum literal.
- //! \returns the successor of the enumeration element.
- //! \throws Invalid parameter if the position is the last one.
- template <typename EC>
- EC succ(EC e)
- {
- BOOSt_ASSERT(pos(e)!=(meta::size<EC>::value-1));
- return val<EC>(pos(e)+1);
- }
- }
-}
-
-#endif
Deleted: sandbox/enums/boost/enums/underlying_type.hpp
==============================================================================
--- sandbox/enums/boost/enums/underlying_type.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,52 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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 BOOST_ENUMS_UNDERLYING_TYPE_HPP
-#define BOOST_ENUMS_UNDERLYING_TYPE_HPP
-
-#include <boost/enums/config.hpp>
-#ifndef BOOST_NO_UNDERLYING_TYPE
- #include <type_traits>
-#endif
-
-namespace boost
-{
- namespace enums
- {
- //! underlying type metafunction
-
- //! \c EC must be an enum type or the emulation of a scoped enum.\n\n
-
- template <typename EC>
- struct underlying_type
- {
-#ifdef BOOST_ENUMS_DOXYGEN_INVOKED
- //! The member typedef \c type name the underlying type of \c T.
- //! When scoped enums are emulated it is defined as \c typename \c EC::underlying_type.
- //! Otherwise is defined as \c std::underlying_type<EC>::type.
- //! This meta-function must be specialized for the compilers providing scoped enums
- //! but don't providing the \c std::underlying_type meta-function.
- typedef see_below type;
-#else
- #ifdef BOOST_NO_SCOPED_ENUMS
- typedef typename EC::underlying_type type;
- #else
- #ifndef BOOST_NO_UNDERLYING_TYPE
- typedef std::underlying_type<EC>::type type;
- #endif
- #endif
-#endif
- };
- }
-}
-
-#endif
Deleted: sandbox/enums/boost/enums/underlying_value.hpp
==============================================================================
--- sandbox/enums/boost/enums/underlying_value.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,36 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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 BOOST_ENUMS_UNDERLYING_VALUE_HPP
-#define BOOST_ENUMS_UNDERLYING_VALUE_HPP
-
-#include <boost/config.hpp>
-#include <boost/enums/enum_type.hpp>
-
-namespace boost {
- namespace enums {
-
- template <typename EC>
- inline
- typename underlying_type<EC>::type
- underlying_value(EC e)
- {
-#ifdef BOOST_NO_SCOPED_ENUMS
- return e.underlying_value();
-#else
- return static_cast<typename underlying_type<EC>::type>(e);
-#endif
- }
- }
-}
-
-#endif // BOOST_ENUMS_UNDERLYING_VALUE_HPP
Deleted: sandbox/enums/boost/enums/val.hpp
==============================================================================
--- sandbox/enums/boost/enums/val.hpp 2011-03-17 19:21:17 EDT (Thu, 17 Mar 2011)
+++ (empty file)
@@ -1,64 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (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.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-/*!
- \file
- \brief
- The header \c <boost/enums/val.hpp> declares a class template \c meta::val<> and
- a function \c val() associating a position to an element of an enumeration.
- */
-
-#ifndef BOOST_ENUMS_VALUE_HPP
-#define BOOST_ENUMS_VALUE_HPP
-
-#include <boost/enums/enum_traits.hpp>
-#include <boost/enums/size.hpp>
-#include <boost/assert.hpp>
-#include <cstddef>
-
-namespace boost
-{
- namespace enums
- {
- namespace meta
- {
- //! meta-function used to associate the position to an element of an enumeration.
-
- //! \note This meta-function must be specialized for each position of the enumeration,
- //! starting from 0 to the predecessor of the size of the enumeration .
- template <typename EC, std::size_t I>
-#ifndef BOOST_ENUMS_DOXYGEN_INVOKED
- struct val;
-#else
- struct val
- {
- constexpr typename enum_type<EC>::type value=<to be defined for each specialization>;
- };
-#endif
-
- }
- //! Value
-
- //! \param p the position
- //! \returns The enum class element associated to the position \c p.
- //! \throws std::out_of_range if the position is out of range.
- template <typename EC>
- EC val(std::size_t p)
- {
- BOOST_ASSERT(p<(meta::size<EC>::value));
- return meta::enum_traits<EC>::val(p);
- }
-
- }
-}
-
-#endif
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