Boost logo

Ublas :

Subject: Re: [ublas] Numeric traits for ublas bounded_vector and matrix
From: Rutger ter Borg (rutger_at_[hidden])
Date: 2010-02-23 11:38:05

Jesse Perla wrote:

> Note here that the ::type is necessary here. But now that I look at it,
> The problem may be that the result_of in this specific case doesn't use
> metafunction forwarding, whereas my naive implementation of static_size
> did... And hence it had the nested value automatically.
> Also note that the following does NOT compile and looks like it should:
> static const int N2 = boost::mpl::if_<
> boost::numeric::bindings::has_static_size< double[10] >,
> boost::numeric::bindings::result_of::size< double[10] >,
> boost::mpl::int_<0>
> static const int J2 = boost::mpl::if_<
> boost::numeric::bindings::has_static_size< std::vector<double> >,
> boost::numeric::bindings::result_of::size< std::vector<double> >,
> boost::mpl::int_<0>

This compiles,

    static const int N = boost::mpl::if_<
        bindings::has_static_size< double[10] >,
        bindings::result_of::size< double[10] >::type,

    std::cout << N << std::endl;

    static const int J = boost::mpl::if_<
        bindings::has_static_size< std::vector<double> >,
        bindings::result_of::size< std::vector<double> >::type,

    std::cout << J << std::endl;

but indeed, perhaps the result_of::size needs extra mpl-stuff so that it is
a better mpl-citizen. Perhaps it needs an extra typedef or something
(apply?), that's an area of the mpl I've haven't used that much yet, so
hints are welcome.