#include <cstdio>
#include <cstdlib>
#include <utility>
#include <new>
struct A {
int i;
A( int i = 0 ) : i( i ) {}
};
template<class T>
struct New {
template <class ... Args>
static T* item( Args ... args ) {
T *data = (T*)malloc( sizeof(T) );
new(data) T( std::forward<Args>( args ) ... );
return data;
}
};
int main() {
A* a = New<A>::item( 42 );
printf( "%i\n", a->i );
return 0;
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGNzdGRsaWI+CiNpbmNsdWRlIDx1dGlsaXR5PgojaW5jbHVkZSA8bmV3PgoKc3RydWN0IEEgewogICAgaW50IGk7CgogICAgQSggaW50IGkgPSAwICkgOiBpKCBpICkge30KfTsKCnRlbXBsYXRlPGNsYXNzIFQ+CnN0cnVjdCBOZXcgewogICAgdGVtcGxhdGUgPGNsYXNzIC4uLiBBcmdzPgogICAgc3RhdGljIFQqIGl0ZW0oIEFyZ3MgLi4uIGFyZ3MgKSB7CiAgICAgICAgVCAqZGF0YSA9IChUKiltYWxsb2MoIHNpemVvZihUKSApOwogICAgICAgIG5ldyhkYXRhKSBUKCBzdGQ6OmZvcndhcmQ8QXJncz4oIGFyZ3MgKSAuLi4gKTsKICAgICAgICByZXR1cm4gZGF0YTsKICAgIH0KfTsKCmludCBtYWluKCkgewoKICAgIEEqIGEgPSBOZXc8QT46Oml0ZW0oIDQyICk7CgogICAgcHJpbnRmKCAiJWlcbiIsIGEtPmkgKTsKCiAgICByZXR1cm4gMDsKfQo=