Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r70437 - in sandbox/enums/boost/enums: . ordinal scoped
From: vicente.botet_at_[hidden]
Date: 2011-03-22 19:39:10


Author: viboes
Date: 2011-03-22 19:39:09 EDT (Tue, 22 Mar 2011)
New Revision: 70437
URL: http://svn.boost.org/trac/boost/changeset/70437

Log:
Enums: create meta::underlying_type and scoping_type + update comments
Text files modified:
   sandbox/enums/boost/enums/containers.hpp | 2
   sandbox/enums/boost/enums/ordinal/first.hpp | 7 ++++-
   sandbox/enums/boost/enums/ordinal/last.hpp | 11 +++++---
   sandbox/enums/boost/enums/ordinal/pos.hpp | 21 ++++++++--------
   sandbox/enums/boost/enums/ordinal/pred.hpp | 11 +++++---
   sandbox/enums/boost/enums/ordinal/size.hpp | 5 +++
   sandbox/enums/boost/enums/ordinal/succ.hpp | 9 ++++---
   sandbox/enums/boost/enums/ordinal/val.hpp | 17 +++++++------
   sandbox/enums/boost/enums/scoped/emulation.hpp | 24 +++++++++++--------
   sandbox/enums/boost/enums/scoped/scoping_type.hpp | 27 +++++++++++++++------
   sandbox/enums/boost/enums/scoped/underlying_type.hpp | 50 +++++++++++++++++++++++++++------------
   11 files changed, 116 insertions(+), 68 deletions(-)

Modified: sandbox/enums/boost/enums/containers.hpp
==============================================================================
--- sandbox/enums/boost/enums/containers.hpp (original)
+++ sandbox/enums/boost/enums/containers.hpp 2011-03-22 19:39:09 EDT (Tue, 22 Mar 2011)
@@ -12,7 +12,7 @@
 /*!
  \file
  \brief
- Include all the enum eontainers.
+ Include all the enum containers.
  */
 
 #ifndef BOOST_ENUMS_CONTAINERS_HPP

Modified: sandbox/enums/boost/enums/ordinal/first.hpp
==============================================================================
--- sandbox/enums/boost/enums/ordinal/first.hpp (original)
+++ sandbox/enums/boost/enums/ordinal/first.hpp 2011-03-22 19:39:09 EDT (Tue, 22 Mar 2011)
@@ -30,8 +30,11 @@
         BOOST_STATIC_CONSTEXPR typename native_type<EC>::type value = enums::meta::val<EC,0>::value;
       };
     }
- //! Returns the the first element of an enumeration
- //! Throws: Nothing
+
+ //! ordinal enum first.
+
+ //! @return the the first element of an enumeration
+ //! @throw Nothing
     template <typename EC>
     BOOST_CONSTEXPR EC first()
     {

Modified: sandbox/enums/boost/enums/ordinal/last.hpp
==============================================================================
--- sandbox/enums/boost/enums/ordinal/last.hpp (original)
+++ sandbox/enums/boost/enums/ordinal/last.hpp 2011-03-22 19:39:09 EDT (Tue, 22 Mar 2011)
@@ -13,8 +13,8 @@
 /*!
  \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.
+ 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
@@ -37,8 +37,11 @@
         BOOST_STATIC_CONSTEXPR typename native_type<EC>::type value = val<EC,size<EC>::value-1>::value;
       };
     }
- //! Returns the the last element of an enumeration
- //! Throws: Nothing
+
+ //! ordinal enum last.
+
+ //! @return the the last element of an enumeration
+ //! @throw Nothing
     template <typename EC>
     BOOST_CONSTEXPR EC last()
     {

Modified: sandbox/enums/boost/enums/ordinal/pos.hpp
==============================================================================
--- sandbox/enums/boost/enums/ordinal/pos.hpp (original)
+++ sandbox/enums/boost/enums/ordinal/pos.hpp 2011-03-22 19:39:09 EDT (Tue, 22 Mar 2011)
@@ -13,8 +13,8 @@
 /*!
  \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
+ 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.
  */
 
@@ -32,30 +32,31 @@
   {
     namespace meta
     {
- //! meta-function used to associate the an element of an enumeration to
+ //! meta-function used to associate an element of an enumeration to
       //! its relative position.
         
- //! \note This meta-function must be specialized for each element of the enumeration.
+ //! @note This meta-function must be specialized for each element of the enumeration.
       template <typename EC, typename native_type<EC>::type V>
 #ifndef BOOST_ENUMS_DOXYGEN_INVOKED
         struct pos;
 #else
         struct pos
         {
+ //! The nested @c value to be defined for each specialization.
             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.
+ //! 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.
+ //! 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
+ //! @param e the enum literal
+ //! @returns the associated position
+ //! @throws Nothing
     template <typename EC>
     std::size_t pos(EC e)
     {

Modified: sandbox/enums/boost/enums/ordinal/pred.hpp
==============================================================================
--- sandbox/enums/boost/enums/ordinal/pred.hpp (original)
+++ sandbox/enums/boost/enums/ordinal/pred.hpp 2011-03-22 19:39:09 EDT (Tue, 22 Mar 2011)
@@ -32,8 +32,9 @@
   {
     namespace meta
     {
- //! meta-function that gets the predecessor of an enumeration element
- //! Pre-condition: the position must be not 0
+ //! meta-function that gets the predecessor of an enumeration element.
+
+ //! @pre: the position must be not 0.
       template <typename EC, typename native_type<EC>::type V>
       struct pred
       {
@@ -42,9 +43,11 @@
           val<EC,pos<EC,V>::value-1>::value;
       };
     }
+
+ //! ordinal enum predecesor.
 
- //! Returns: the predecessor of the enumeration element
- //! Throws: Invalid parameter if the position is 0
+ //! @return the predecessor of the enumeration element.
+ //! @throw Invalid parameter if the position is 0.
     template <typename EC>
     BOOST_CONSTEXPR EC pred(EC e)
     {

Modified: sandbox/enums/boost/enums/ordinal/size.hpp
==============================================================================
--- sandbox/enums/boost/enums/ordinal/size.hpp (original)
+++ sandbox/enums/boost/enums/ordinal/size.hpp 2011-03-22 19:39:09 EDT (Tue, 22 Mar 2011)
@@ -28,17 +28,20 @@
     namespace meta {
         //! meta-function used to get the number of elements of an enumeration.
         
- //! \note This meta-function must be specialized for each enumeration.
+ //! @note This meta-function must be specialized for each enumeration.
         template <typename EC>
 #ifndef BOOST_ENUMS_DOXYGEN_INVOKED
         struct size;
 #else
         struct size
         {
+ //! The nested @c value to be defined for each specialization.
             constexpr std::size_t value=<to be defined for each specialization>;
         };
 #endif
     }
+ //! @return the number of elements of an enumeration @c EC.
+ //! @throw Nothing.
     template <typename EC>
     std::size_t size()
     {

Modified: sandbox/enums/boost/enums/ordinal/succ.hpp
==============================================================================
--- sandbox/enums/boost/enums/ordinal/succ.hpp (original)
+++ sandbox/enums/boost/enums/ordinal/succ.hpp 2011-03-22 19:39:09 EDT (Tue, 22 Mar 2011)
@@ -32,8 +32,9 @@
   {
     namespace meta
     {
- //! meta-function that gets the successor of an enumeration element
- //! Pre-condition: the position must not be the last one
+ //! meta-function that gets the successor of an enumeration element.
+
+ //! @pre the position must not be the last one
       template <typename EC, typename native_type<EC>::type V>
       struct succ
       {
@@ -47,8 +48,8 @@
     //! enum succesor.
       
     //! param e the enum literal.
- //! \returns the successor of the enumeration element.
- //! \throws Invalid parameter if the position is the last one.
+ //! @returns the successor of the enumeration element.
+ //! @throws Invalid parameter if the position is the last one.
     template <typename EC>
     EC succ(EC e)
     {

Modified: sandbox/enums/boost/enums/ordinal/val.hpp
==============================================================================
--- sandbox/enums/boost/enums/ordinal/val.hpp (original)
+++ sandbox/enums/boost/enums/ordinal/val.hpp 2011-03-22 19:39:09 EDT (Tue, 22 Mar 2011)
@@ -13,8 +13,8 @@
 /*!
  \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.
+ 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
@@ -33,7 +33,7 @@
     {
       //! 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,
+ //! @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
@@ -41,16 +41,17 @@
 #else
         struct val
         {
- constexpr typename native_type<EC>::type value=<to be defined for each specialization>;
+ //! The nested @c value to be defined for each specialization.
+ constexpr typename native_type<EC>::type value=<to be defined for each specialization>;
         };
 #endif
         
     }
- //! Value
+ //! ordinal enum 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.
+ //! @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)
     {

Modified: sandbox/enums/boost/enums/scoped/emulation.hpp
==============================================================================
--- sandbox/enums/boost/enums/scoped/emulation.hpp (original)
+++ sandbox/enums/boost/enums/scoped/emulation.hpp 2011-03-22 19:39:09 EDT (Tue, 22 Mar 2011)
@@ -68,11 +68,13 @@
   #define BOOST_ENUMS_DETAIL_SCOPING_TYPE_SPEC(EC) \
       namespace boost { \
         namespace enums { \
- template <> \
- struct scoping_type<native_type<EC>::type> \
- { \
- typedef EC type; \
- }; \
+ namespace meta { \
+ template <> \
+ struct scoping_type<native_type<EC>::type> \
+ { \
+ typedef EC type; \
+ }; \
+ } \
         } \
       }
 
@@ -93,11 +95,13 @@
     #define BOOST_ENUMS_DETAIL_UNDERLYING_TYPE_SPEC(EC, UT) \
       namespace boost { \
         namespace enums { \
- template <> \
- struct underlying_type<EC> \
- { \
- typedef UT type; \
- }; \
+ namespace meta { \
+ template <> \
+ struct underlying_type<EC> \
+ { \
+ typedef UT type; \
+ }; \
+ } \
         } \
       }
 

Modified: sandbox/enums/boost/enums/scoped/scoping_type.hpp
==============================================================================
--- sandbox/enums/boost/enums/scoped/scoping_type.hpp (original)
+++ sandbox/enums/boost/enums/scoped/scoping_type.hpp 2011-03-22 19:39:09 EDT (Tue, 22 Mar 2011)
@@ -25,17 +25,28 @@
 {
   namespace enums
   {
- /*! meta-function used to get the wrapping class of an enum when emulation
+ namespace meta
+ {
+ /*! meta-function to be specialized for each emulated enum class.
+ */
+ template <typename EC_type>
+ struct scoping_type
+ {
+ //! By default this metafunction defines it as if scoped enums where supported.
+ typedef EC_type type;
+ };
+ }
+ /*! 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.
+
+ @note 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;
- };
+ struct scoping_type
+ {
+ //! Depending on whethere the compiler supports scoped enums or not the nested type must be the same type or the emulated one.
+ typedef typename meta::scoping_type<EC_type>::type type;
+ };
   }
 }
 

Modified: sandbox/enums/boost/enums/scoped/underlying_type.hpp
==============================================================================
--- sandbox/enums/boost/enums/scoped/underlying_type.hpp (original)
+++ sandbox/enums/boost/enums/scoped/underlying_type.hpp 2011-03-22 19:39:09 EDT (Tue, 22 Mar 2011)
@@ -22,28 +22,46 @@
 {
   namespace enums
   {
- //! underlying type metafunction
+ namespace meta
+ {
+ //! customization-point for 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
+ //! <b>Requires</b> \c EC must be an enum type or the emulation of a scoped enum.\n\n
+ //! 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 typename std::underlying_type<EC>::type type;
+#endif
+#endif
+#endif
+ };
+ }
+ //! underlying type metafunction
+
+ //! <b>Requires</b> \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;
+ //! The member typedef \c type names the underlying type of \c T.
+ //! It is defined as \c meta::underlying_type<EC>::type which could need specialization.
+ //! @see boost::enums::meta::underlying_type
+ 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
+ typedef typename meta::underlying_type<EC>::type type;
 #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