c++ - Having a problem with placement-new! -


I'm having trouble by giving an example of my reference-count indicator and class Using Debugger in my Array class, it seems that the constructor is never called (which disturbs the reference-count and causes the default from below the line)!

My Push_back function is:

  Repeat zero push_back (constant tee element) {if (length> = maximum) (max> gt; 0 ? Max * 2: 1); New (more data [length]) t (element); ++ Length; }  

The reference-count is similar to what is said after the new one. I'm pretty sure this is a problem, but I do not understand why the creator will not be asked. In addition, the Pointer :: Pointer (...) compile it to an indicator & lt; T & gt; & amp; Or a constant pointer & lt; T & gt; & amp; (Huh?), And despite the problem!

Maybe there are some details about the appointment I am not taking into meditation. If anyone has some ideas, then he will be very much appreciated!

Edit: [As requested, a relevant part from the pointer]

  // ... private: T * P; public:     //! Constructor Pointer (): P (0) {} //! Copy creator template & lt; Class X & gt; Pointer (pointer  and others): P (Other GetPointer ()) {if (p) p-> incrementRef (); } //! Manufacturer (set and increment) indicator (T * P): P (P) {if (P) P-> increment (); } //! District (curves p) ~ indicator () {if (p) p-> gt; DecrementRef (); } // ...  

I also have operator = pointers & lt; T & gt; & amp; And T * , as well as operator -> and operator T *

Your comment and your code are out of sync:

  //! Copy creator template & lt; Class X & gt; Pointer (pointer  and other)  

A constructor created by a class template is not copy constructor (12.8 [class.copy in a footnote Is] which makes it clear), so the compiler will not be prevented from making an copy constructor for you. This generated creator will be a better match for a standard copy because the non-templates function overload Resolve the template function in resolution Nd is.

It appears that you need to write a clear copy constructor to get the desired effect in your indicator class


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -