Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2003-08-11 13:21:35


I believe the intention of the container_facade (which I was calling
ptr_array) was that the initialization would be just of the pointer, so
the array itself would not be copied. The motivation for something like
ptr_array (versus using std::vector) is that sometimes you get chunks of
memory from non-C++ sources (like C or Fortran libraries) and need a way
to deal with them in C++ in an efficient manner.

On Mon, 11 Aug 2003, Alisdair Meredith wrote:
alisda> Robert Ramey wrote:
alisda>
alisda> > const int array[] = {1, 2, 3, 4};
alisda> > boost::container_facade<int> cfa(array, sizeof(array)/sizeof(int));
alisda>
alisda> I guess my problem is I still don't understand what is wrong with
alisda>
alisda> const boost::array< int, 4 > = { 1, 2, 3, 4 };
alisda>
alisda> in this case.
alisda>
alisda> If you are referring to having to dictate the size of the array in
alisda> advance, rather than deduce it, that is a known deficiency and I would
alisda> welcome any solutions for this!
alisda>
alisda> [I have proposed array to the ISO committee and this is one of the
alisda> issues that I suspect may hold back its adoption]
alisda>
alisda>
alisda> As for making the copy above:
alisda> Would a constructor template perform the deduction correctly?
alisda>
alisda> template< typename T, unsigned int N >
alisda> container_facade( const T[N] source )
alisda> {
alisda> std::copy( source, source + N, m_data );
alisda> }
alisda>

----------------------------------------------------------------------
 Jeremy Siek http://php.indiana.edu/~jsiek/
 Ph.D. Student, Indiana Univ. B'ton email: jsiek_at_[hidden]
 C++ Booster (http://www.boost.org) office phone: (812) 855-3608
----------------------------------------------------------------------


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