Is avoding calling default constructor possible?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Is it possible to create array of objects T without calling the
default constructors T::T() ?
Calling other constructor instead would be great.
Leaving the memory uninitalize is ok as well, as I can do placement new later.

I want to avoid char* casting to T* because it breaks strict aliasing rules
(stopping optimizations from happening and slowing my program by 25%.)

Answer to this question would provide walkaround to the aliasing
problem I described few days ago.

Thanks in advance for any ideas
Lukasz Lew


PS
Manual says that uinon is the way to go with strict-aliasing, but unfortunately:

union {
  char tab [N * sizeof(Elt)];
  Elt tab2 [N];
};

Doesn't compile because Elt *has* default constructor.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux