Mixing boost multi_array and optional with C ++ 11 unique_ptr not working

I put together a bleeding setup using g ++ 4.7 (although at the moment I'm still using boost 1.48, which came with sudo apt-get boost-all-devDebian Wheezy).

My code is set up where the multidimensional unique_ptr array is the logical data structure. But multi_array, it seems, it cannot even build an empty array from one element if it has unique_ptr. So this works:

boost::multi_array<int, 1> arrWorks (boost::extents[1]);

But this is not so:

boost::multi_array< unique_ptr<int>, 1> arrFails (boost::extents[1]);

I believe the corresponding complaint from the compiler is:

/usr/include/++/4.7/bits/stl_uninitialized.h: 225: required from 'void std :: uninitialized_fill_n (_ForwardIterator, _Size, const _Tp &) [with _ForwardIterator = std :: unique_ptr *; _Size = unsigned int; _Tp = std :: unique_ptr]

optional< unique_ptr<...> >, , :

https://svn.boost.org/trac/boost/ticket/1841

(: boost:: optional?)

, :

boost::optional< unique_ptr<int> > optWorks (new int);

// Fails
boost::optional< unique_ptr<int> > optFails (std::move(optWorks));

, , , . , , unique_ptr . ", , ".

- ? ? - , ?

+5

All Articles