• Advertisement
Sign in to follow this  

custom allocator error

This topic is 1940 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been working on a very simple custom stl allocator and came across a funny error. I'm using VS2012 with the new CTP compiler. Now I was under the impression that with the new allocator_traits an allocator didn't need to supply a construct and destroy function (pg. 417 of n3337 states that default implementations of these functions are supplied by allocator_traits) but attempting to use the allocator with a std::vector caused a compile error stating these functions were missing. So I added them in, using the definitions from the standard and I got another peculiar error in the destroy function. The error I get is:
error C2039: '˜T' : is not a member of 'std::_Container_proxy'

the function being:
template <typename T, size_t N> void fixed_allocator<T,N>::destroy (pointer p) { p->˜T(); }

Now perhaps this is just a silly error on my part (in which case I apologize in advance), but there's 3 problems here:

1st is why do I even need to define construct()/destroy()? The standard seems pretty clear that these are not required. Is this a shortcoming of the VS2012 stl implementation or did I read the standard wrong?

2nd how is it even possible for a type not to have a destructor? I know you can declare a destructor private but that gives an access error, not an 'is not a member' error. I imagine that something like '~T() = delete;' might produce this error, but the declaration of 'std::_Container_proxy' is:

// CLASS _Container_proxy
struct _Container_proxy
{ // store head of iterator chain and back pointer
: _Mycont(0), _Myfirstiter(0)
{ // construct from pointers
const _Container_base12 *_Mycont;
_Iterator_base12 *_Myfirstiter;

Which has nothing of the sort. So this seems to be a really strange error.

3rd how would one go about fixing this?

Share this post

Link to post
Share on other sites
Ok figured out problem #2 and #3 (#1 still stands though). I had copied/pasted the p->~T(); from the standard pdf. Except that the ~ wasn't actually a tilde, but a similar looking unicode character of some kinda. Look nearly identical, but wasn't.... Ahh well, if I didn't make mistakes I wouldn't learn.

As far as #1 is concerned, I think its just the VS2012 library hasn't caught up, as the boost::container::vector works fine without construct and destroy.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement