|
Boost : |
From: Neal D. Becker (ndbecker2_at_[hidden])
Date: 2004-05-07 07:52:47
Neal D. Becker wrote:
> This simple test fails to compile on gcc-3.3.3. Any thoughts?
>
> #include <boost/collection_traits.hpp>
> #include <iostream>
> #include <iterator>
> #include <algorithm>
>
> using namespace std;
>
> int F (int size) {
> int a[size];
>
> copy (boost::begin (a), boost::end (a), ostream_iterator<int> (cout, "
> "));
> }
>
Adding these specializations fixes the variable size array problem, at least
with gcc-3.4. Is there a reason for not using these?
----------------------------------------
template< typename T >
inline const T* begin( const T* array)
{
return array;
}
template< typename T >
inline T* begin( T* array)
{
return array;
}
-----------------------------------------
collections has the more complex:
template< typename T, std::size_t sz >
inline const T* begin( const T (&array)[sz] )
{
return array;
}
template< typename T, std::size_t sz >
inline T* begin( T (&array)[sz] )
{
return array;
}
-------------------------------------------
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk