Boost logo

Boost :

From: Phil Bouchard (philippe_at_[hidden])
Date: 2008-06-20 04:36:49


Hi,

Upon trying to create the new shifted_allocator class that is instead to be
passed as a template parameter on STL containers, I got stuck in a circle or
errors. I came to realize there was not way to replace internal pointers
used by containers with smart pointers... which is very unfortunate. There
are different solution I could take but hopefully I won't need them.

By trying compiling shifted_ptr_test2.cpp in the Sandbox we'll get the
following errors. I believe shifted_allocator (in shifted_allocator.hpp)
should be represented the way it is but I may likely got something wrong
because I haven't followed the verdict on this in previous posts:

...stl_vector.h: In member function `__gnu_cxx::__normal_iterator<typename
_Alloc::const_pointer, std::vector<_Tp, _Alloc> > std::vector<_Tp,
_Alloc>::begin() const [with _Tp = boost::detail::sh::shifted_ptr<vector>,
_Alloc = boost::shifted_allocator<boost::detail::sh::shifted_ptr<vector>
>]':
...stl_vector.h:221: instantiated from `std::vector<_Tp,
_Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp =
boost::detail::sh::shifted_ptr<vector>, _Alloc =
boost::shifted_allocator<boost::detail::sh::shifted_ptr<vector> >]'
shifted_ptr_test2.cpp:66: instantiated from here

...stl_vector.h:322: error: no matching function for call to
`__gnu_cxx::__normal_iterator<const
boost::detail::sh::shifted<boost::detail::sh::shifted_ptr<vector> >*,
std::vector<boost::detail::sh::shifted_ptr<vector>,
boost::shifted_allocator<boost::detail::sh::shifted_ptr<vector> > >
>::__normal_iterator(boost::detail::sh::shifted_ptr<vector>* const&)'

...stl_iterator.h:587: note: candidates are:
__gnu_cxx::__normal_iterator<const
boost::detail::sh::shifted<boost::detail::sh::shifted_ptr<vector> >*,
std::vector<boost::detail::sh::shifted_ptr<vector>,
boost::shifted_allocator<boost::detail::sh::shifted_ptr<vector> > >
>::__normal_iterator(const __gnu_cxx::__normal_iterator<const
boost::detail::sh::shifted<boost::detail::sh::shifted_ptr<vector> >*,
std::vector<boost::detail::sh::shifted_ptr<vector>,
boost::shifted_allocator<boost::detail::sh::shifted_ptr<vector> > > >&)
...stl_iterator.h:603: note:
__gnu_cxx::__normal_iterator<_Iterator, _Container>::__normal_iterator(const
_Iterator&) [with _Iterator = const
boost::detail::sh::shifted<boost::detail::sh::shifted_ptr<vector> >*,
_Container = std::vector<boost::detail::sh::shifted_ptr<vector>,
boost::shifted_allocator<boost::detail::sh::shifted_ptr<vector> > >]
...stl_iterator.h:600: note:
__gnu_cxx::__normal_iterator<_Iterator, _Container>::__normal_iterator()
[with _Iterator = const
boost::detail::sh::shifted<boost::detail::sh::shifted_ptr<vector> >*,
_Container = std::vector<boost::detail::sh::shifted_ptr<vector>,
boost::shifted_allocator<boost::detail::sh::shifted_ptr<vector> > >]

The Vault version presents the same code except the comment of line 67 & 68
in shifted_ptr_test2.cpp will need to be swapped:
http://www.boostpro.com/vault/index.php?action=downloadfile&filename=shifted_ptr.zip&directory=Memory

-Phil


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