Boost logo

Ublas :

Subject: Re: [ublas] [bindings][traits] Stricter traits
From: Rutger ter Borg (rutger_at_[hidden])
Date: 2009-04-19 09:34:56

Karl Meerbergen wrote:

> Rutger,
> Strictly speaking the bindings are only defined for numeric
> value_type's... is_scalar would be is_numeric?

I agree, I've committed a is_numeric metafunction (real/complex/integral

> This specialization would exist, but not be useful in any bindings.

That's right, I would like to have "not useful" equal to "non existent", so
the metafunction is_bindable_vector works correct. I've committed the piece
of code below [see 1] to vector_traits, this seems to give what I want. It
checks if value_type defined by detail_traits is a numeric type. If it is,
is derives from detail_traits.

Now, is_bindable_vector has more correct type-outputs,

vector< int > -> true
vector< vector< int > > -> false (fixed)
int, void, etc. -> false
ublas_vector<double> -> true
ublas_matrix -> false

etc. I propose we do the same for matrix_traits.




  // vector_traits<> generic version: no specialization(s)
  template< typename V, typename Enable = void>
  struct vector_traits {};

  // vector_traits<>, specializes if ::value_type is numeric
  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 >:
    vector_detail_traits< typename boost::remove_const<V>::type, V > {};