Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52902 - trunk/boost/pending
From: asutton_at_[hidden]
Date: 2009-05-11 08:58:38


Author: asutton
Date: 2009-05-11 08:58:37 EDT (Mon, 11 May 2009)
New Revision: 52902
URL: http://svn.boost.org/trac/boost/changeset/52902

Log:
Added a specialization of retag_property_list that will correctly retag
bundled properties given in "property form".

Text files modified:
   trunk/boost/pending/property.hpp | 100 +++++++++++++++++++++++++--------------
   1 files changed, 64 insertions(+), 36 deletions(-)

Modified: trunk/boost/pending/property.hpp
==============================================================================
--- trunk/boost/pending/property.hpp (original)
+++ trunk/boost/pending/property.hpp 2009-05-11 08:58:37 EDT (Mon, 11 May 2009)
@@ -1,4 +1,4 @@
-// (C) Copyright Jeremy Siek 2004
+// (C) Copyright Jeremy Siek 2004
 // 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)
@@ -10,7 +10,7 @@
 
 namespace boost {
 
- struct no_property {
+ struct no_property {
     typedef no_property tag_type;
     typedef no_property next_type;
     typedef no_property value_type;
@@ -47,14 +47,14 @@
   };
 
   template <class P>
- struct has_property {
+ struct has_property {
     BOOST_STATIC_CONSTANT(bool, value = true);
     typedef true_type type;
   };
   template <>
- struct has_property<no_property> {
- BOOST_STATIC_CONSTANT(bool, value = false);
- typedef false_type type;
+ struct has_property<no_property> {
+ BOOST_STATIC_CONSTANT(bool, value = false);
+ typedef false_type type;
   };
 
 } // namespace boost
@@ -72,7 +72,7 @@
     typedef typename detail::build_property_tag_value_alist<PropertyList>::type AList;
     typedef typename detail::ev_selector<AList>::type Extractor;
     typedef typename Extractor::template bind_<AList,Tag>::type type;
-#endif
+#endif
   };
 
   template <class Tag2>
@@ -82,9 +82,9 @@
   }
 
   template <class Tag1, class Tag2, class T1, class Base>
- inline typename property_value<property<Tag1,T1,Base>, Tag2>::type&
+ inline typename property_value<property<Tag1,T1,Base>, Tag2>::type&
   get_property_value(property<Tag1,T1,Base>& p, Tag2 tag2) {
- BOOST_STATIC_CONSTANT(bool,
+ BOOST_STATIC_CONSTANT(bool,
                           match = (detail::same_property<Tag1,Tag2>::value));
     typedef property<Tag1,T1,Base> Prop;
     typedef typename property_value<Prop, Tag2>::type T2;
@@ -94,9 +94,9 @@
   }
   template <class Tag1, class Tag2, class T1, class Base>
   inline
- const typename property_value<property<Tag1,T1,Base>, Tag2>::type&
+ const typename property_value<property<Tag1,T1,Base>, Tag2>::type&
   get_property_value(const property<Tag1,T1,Base>& p, Tag2 tag2) {
- BOOST_STATIC_CONSTANT(bool,
+ BOOST_STATIC_CONSTANT(bool,
                           match = (detail::same_property<Tag1,Tag2>::value));
     typedef property<Tag1,T1,Base> Prop;
     typedef typename property_value<Prop, Tag2>::type T2;
@@ -107,32 +107,60 @@
 
  namespace detail {
 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
- template<typename FinalTag, typename FinalType>
- struct retag_property_list
- {
- typedef property<FinalTag, FinalType> type;
- typedef FinalType retagged;
- };
-
- template<typename FinalTag, typename Tag, typename T, typename Base>
- struct retag_property_list<FinalTag, property<Tag, T, Base> >
- {
- private:
- typedef retag_property_list<FinalTag, Base> next;
-
- public:
- typedef property<Tag, T, typename next::type> type;
- typedef typename next::retagged retagged;
- };
-
- template<typename FinalTag>
- struct retag_property_list<FinalTag, no_property>
- {
- typedef no_property type;
- typedef no_property retagged;
- };
+ /** @internal @name Retag Property List
+ * This metafunction is used internally to normalize a property if it is
+ * actually modeling a property. Specifically this is used in Boost.Graph
+ * to map user-provided classes into bundled properties.
+ */
+ //@{
+ // One base case of the recursive form (see below). This matches any
+ // retag request that does not include a property<...> or no_property as
+ // the FinalType. This is used for generating bundles in Boost.Graph.
+ template<typename FinalTag, typename FinalType>
+ struct retag_property_list
+ {
+ typedef property<FinalTag, FinalType> type;
+ typedef FinalType retagged;
+ };
+
+ // Recursively retag the nested property list.
+ template<typename FinalTag, typename Tag, typename T, typename Base>
+ struct retag_property_list<FinalTag, property<Tag, T, Base> >
+ {
+ private:
+ typedef retag_property_list<FinalTag, Base> next;
+
+ public:
+ typedef property<Tag, T, typename next::type> type;
+ typedef typename next::retagged retagged;
+ };
+
+ // This base case will correctly deduce the final property type if the
+ // retagged property is given in property form. This should not hide
+ // the base case below.
+ // NOTE: This addresses a problem of layering bundled properties in the BGL
+ // where multiple retaggings will fail to deduce the correct retagged
+ // type.
+ template<typename FinalTag, typename FinalType>
+ struct retag_property_list<FinalTag, property<FinalTag, FinalType> >
+ {
+ public:
+ typedef property<FinalTag, FinalType> type;
+ typedef FinalType retagged;
+ };
+
+ // A final base case of the retag_propert_list, this will terminate a
+ // properly structured list.
+ template<typename FinalTag>
+ struct retag_property_list<FinalTag, no_property>
+ {
+ typedef no_property type;
+ typedef no_property retagged;
+ };
+ //@}
 #endif
- }
+} // namespace detail
+
 } // namesapce boost
 
 #endif /* BOOST_PROPERTY_HPP */


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk