Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52599 - sandbox/numeric_bindings/boost/numeric/bindings/traits
From: rutger_at_[hidden]
Date: 2009-04-26 06:31:16


Author: rutger
Date: 2009-04-26 06:31:15 EDT (Sun, 26 Apr 2009)
New Revision: 52599
URL: http://svn.boost.org/trac/boost/changeset/52599

Log:
Conditional specialization for matrix_traits, given contained value_type

Text files modified:
   sandbox/numeric_bindings/boost/numeric/bindings/traits/matrix_traits.hpp | 16 +++++++++++++---
   sandbox/numeric_bindings/boost/numeric/bindings/traits/vector_traits.hpp | 9 +++++----
   2 files changed, 18 insertions(+), 7 deletions(-)

Modified: sandbox/numeric_bindings/boost/numeric/bindings/traits/matrix_traits.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/traits/matrix_traits.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/traits/matrix_traits.hpp 2009-04-26 06:31:15 EDT (Sun, 26 Apr 2009)
@@ -15,6 +15,8 @@
 #define BOOST_NUMERIC_BINDINGS_TRAITS_MATRIX_TRAITS_HPP
 
 #include <boost/numeric/bindings/traits/config.hpp>
+#include <boost/utility/enable_if.hpp>
+#include <boost/numeric/bindings/traits/is_numeric.hpp>
 
 #ifndef BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS
 
@@ -43,9 +45,17 @@
     typedef MType matrix_type;
   };
 
- /// matrix_traits<> generic version:
- template <typename M>
- struct matrix_traits : matrix_detail_traits< typename boost::remove_const<M>::type, M> {
+ /// matrix_traits<> generic version: no specialization(s)
+ template< typename M, typename Enable = void >
+ struct matrix_traits {};
+
+ /// matrix_traits<> generic version which will be
+ /// enabled if the matrix_detail_traits<>::value_type is a numeric type
+ template< typename M >
+ struct matrix_traits< M, typename boost::enable_if< is_numeric<
+ typename matrix_detail_traits< typename boost::remove_const<M>::type, M>::value_type
+ > >::type >:
+ matrix_detail_traits< typename boost::remove_const<M>::type, M> {
     // typedefs:
     // matrix_structure
     // ordering_type

Modified: sandbox/numeric_bindings/boost/numeric/bindings/traits/vector_traits.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/traits/vector_traits.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/traits/vector_traits.hpp 2009-04-26 06:31:15 EDT (Sun, 26 Apr 2009)
@@ -59,11 +59,12 @@
   template< typename V, typename Enable = void>
   struct vector_traits {};
 
- // vector_traits<>, specializes if ::value_type is numeric
+ // vector_traits<>, derives from vector_detail_traits<> if
+ // vector_detail_traits<>::value_type is a numeric type
   template <typename V>
- struct vector_traits< V, typename boost::enable_if<
- is_numeric< typename vector_detail_traits< typename boost::remove_const<V>::type, V >::value_type >
- >::type >:
+ struct vector_traits< V, typename boost::enable_if< is_numeric<
+ typename vector_detail_traits< typename boost::remove_const<V>::type, V >::value_type
+ > >::type >:
     vector_detail_traits< typename boost::remove_const<V>::type, V > {};
 
   ///////////////////////////


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