CreateAt

Files CCore/inc/gadget/CreateAt.h CCore/src/gadget/CreateAt.cpp

CreateAt() creates an object at the given place. This function is required to manipulate members of non-trivial unions.


template <class T,class ... SS>
void CreateAt(T &obj,SS && ... ss)
 {
  new(PlaceAt(&obj)) T( std::forward<SS>(ss)... );
 }

For example,


union Union
 {
  A a;
  B b; // A and B both have trivial destructors

  Union() {}
 };

To make an actual the member a of the union you can use the function CreateAt().


Union u;

CreateAt(u.a);