• Create Account

## custom allocator error

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

### #1Ryan_001  Prime Members

Posted 26 November 2012 - 04:22 PM

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
_Container_proxy()
: _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?

### #2Ryan_001  Prime Members

Posted 27 November 2012 - 05:32 PM

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.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.