Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60366 - trunk/boost/property_map
From: jewillco_at_[hidden]
Date: 2010-03-08 14:44:00


Author: jewillco
Date: 2010-03-08 14:44:00 EST (Mon, 08 Mar 2010)
New Revision: 60366
URL: http://svn.boost.org/trac/boost/changeset/60366

Log:
Made property_traits members conditionally defined to enable SFINAE on functions that use it; code from Steven Watanabe
Text files modified:
   trunk/boost/property_map/property_map.hpp | 36 ++++++++++++++++++++++++++++++++++++
   1 files changed, 36 insertions(+), 0 deletions(-)

Modified: trunk/boost/property_map/property_map.hpp
==============================================================================
--- trunk/boost/property_map/property_map.hpp (original)
+++ trunk/boost/property_map/property_map.hpp 2010-03-08 14:44:00 EST (Mon, 08 Mar 2010)
@@ -19,6 +19,8 @@
 #include <boost/concept_archetype.hpp>
 #include <boost/mpl/assert.hpp>
 #include <boost/mpl/or.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/has_xxx.hpp>
 #include <boost/type_traits/is_same.hpp>
 
 namespace boost {
@@ -26,6 +28,39 @@
   //=========================================================================
   // property_traits class
 
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(key_type);
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(value_type);
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(reference);
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(category);
+
+ template<class PA>
+ struct is_property_map :
+ boost::mpl::and_<
+ has_key_type<PA>,
+ has_value_type<PA>,
+ has_reference<PA>,
+ has_category<PA>
+ >
+ {};
+
+ template <typename PA>
+ struct default_property_traits {
+ typedef typename PA::key_type key_type;
+ typedef typename PA::value_type value_type;
+ typedef typename PA::reference reference;
+ typedef typename PA::category category;
+ };
+
+ struct null_property_traits {};
+
+ template <typename PA>
+ struct property_traits :
+ boost::mpl::if_<is_property_map<PA>,
+ default_property_traits<PA>,
+ null_property_traits>::type
+ {};
+
+#if 0
   template <typename PA>
   struct property_traits {
     typedef typename PA::key_type key_type;
@@ -33,6 +68,7 @@
     typedef typename PA::reference reference;
     typedef typename PA::category category;
   };
+#endif
 
   //=========================================================================
   // property_traits category tags


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