Boost logo

Boost :

From: Alexander Nasonov (alnsn-boost_at_[hidden])
Date: 2005-05-27 04:09:36


Arkadiy Vertleyb <vertleyb <at> hotmail.com> writes:

> I think they are:
>
> template<class T>
> char foo(vector<T>& v)[id1][id2][id3];
>
> But how would this work? This array type will stay inside the function.

#include <boost/mpl/assert.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/vector_c.hpp>

char (&foo())[9][8][7][6];

int main()
{
    using namespace boost::mpl;

    typedef vector_c<
        int
      , sizeof(foo()) / sizeof(foo()[0])
      , sizeof(foo()[0]) / sizeof(foo()[0][0])
      , sizeof(foo()[0][0]) / sizeof(foo()[0][0][0])
      , sizeof(foo()[0][0][0]) / sizeof(foo()[0][0][0][0])
> vec;

      BOOST_MPL_ASSERT(( equal< vec, vector_c<int,9,8,7,6> > ));
}

Sizes may become very huge, though.

> We need a function to return the object of certain _size_
> in order to pass it outside...

I don't understand it.

--
Alexander Nasonov

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk