You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
488 B
39 lines
488 B
|
16 years ago
|
#include <iostream>
|
||
|
|
|
||
|
|
class Hello
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
Hello ()
|
||
|
|
{}
|
||
|
|
|
||
|
|
~Hello ()
|
||
|
|
{}
|
||
|
|
|
||
|
|
void act ()
|
||
|
|
{ std::cout << "Hello, world!" << std::endl; }
|
||
|
|
};
|
||
|
|
|
||
|
|
|
||
|
|
template <class T>
|
||
|
|
struct Foo
|
||
|
|
{
|
||
|
|
T* _M_allocate_single_object ()
|
||
|
|
{
|
||
|
|
return new T;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
static void __attribute__ (( constructor )) PWLIB_StaticLoader() {
|
||
|
|
Foo<Hello> allocator;
|
||
|
|
Hello* salut = allocator._M_allocate_single_object ();
|
||
|
|
salut->act ();
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
int
|
||
|
|
main (int /*argc*/,
|
||
|
|
char* /*argv*/[])
|
||
|
|
{
|
||
|
|
return 0;
|
||
|
|
}
|