Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52399 - sandbox/numeric_bindings/boost/numeric/bindings/traits
From: rutger_at_[hidden]
Date: 2009-04-15 06:25:40


Author: rutger
Date: 2009-04-15 06:25:39 EDT (Wed, 15 Apr 2009)
New Revision: 52399
URL: http://svn.boost.org/trac/boost/changeset/52399

Log:
Initial working version of is_bindable_vector and is_bindable_matrix metafunctions

Text files modified:
   sandbox/numeric_bindings/boost/numeric/bindings/traits/is_bindable_matrix.hpp | 17 ++++++++++++++++-
   sandbox/numeric_bindings/boost/numeric/bindings/traits/is_bindable_vector.hpp | 18 +++++++++++++++++-
   2 files changed, 33 insertions(+), 2 deletions(-)

Modified: sandbox/numeric_bindings/boost/numeric/bindings/traits/is_bindable_matrix.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/traits/is_bindable_matrix.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/traits/is_bindable_matrix.hpp 2009-04-15 06:25:39 EDT (Wed, 15 Apr 2009)
@@ -10,6 +10,7 @@
 #define BOOST_NUMERIC_BINDINGS_TRAITS_IS_BINDABLE_MATRIX_HPP
 
 #include <boost/mpl/bool.hpp>
+#include <boost/numeric/bindings/traits/matrix_traits.hpp>
 
 namespace boost {
 namespace numeric {
@@ -17,7 +18,21 @@
 namespace traits {
 
 template< typename T >
-struct is_bindable_matrix: boost::mpl::bool_<false> {};
+struct is_bindable_matrix {
+
+ typedef char yes;
+ typedef char (&no)[2];
+
+ template< typename M >
+ static yes tester( typename matrix_traits<M>::pointer );
+
+ template< typename M >
+ static no tester( ... );
+
+ static bool const value = sizeof(tester<T>(0)) == sizeof(yes);
+
+ typedef mpl::bool_<value> type;
+};
 
 }}}}
 

Modified: sandbox/numeric_bindings/boost/numeric/bindings/traits/is_bindable_vector.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/traits/is_bindable_vector.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/traits/is_bindable_vector.hpp 2009-04-15 06:25:39 EDT (Wed, 15 Apr 2009)
@@ -10,6 +10,7 @@
 #define BOOST_NUMERIC_BINDINGS_TRAITS_IS_BINDABLE_VECTOR_HPP
 
 #include <boost/mpl/bool.hpp>
+#include <boost/numeric/bindings/traits/vector_traits.hpp>
 
 namespace boost {
 namespace numeric {
@@ -17,7 +18,22 @@
 namespace traits {
 
 template< typename T >
-struct is_bindable_vector: boost::mpl::bool_<false> {};
+struct is_bindable_vector {
+
+ typedef char yes;
+ typedef char (&no)[2];
+ struct other_type;
+
+ template< typename V >
+ static yes tester( typename vector_traits<V>::pointer );
+
+ template< typename V >
+ static no tester( ... );
+
+ static bool const value = sizeof(tester<T>(0)) == sizeof(yes);
+
+ typedef mpl::bool_<value> type;
+};
 
 }}}}
 


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