2013-09-29 01:08:15 +02:00
|
|
|
|
2013-09-30 00:42:27 +02:00
|
|
|
#include "clang-static-init.hpp"
|
2013-09-29 01:08:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace test {
|
|
|
|
|
|
|
|
|
|
|
2013-10-06 18:50:53 +02:00
|
|
|
int Subject::creationCount = 0;
|
2013-09-29 01:08:15 +02:00
|
|
|
|
|
|
|
|
Subject::Subject()
|
|
|
|
|
{
|
2013-10-06 18:50:53 +02:00
|
|
|
++creationCount;
|
|
|
|
|
std::cout << "Subject("<<creationCount<<")\n";
|
2013-09-29 01:08:15 +02:00
|
|
|
}
|
2013-10-06 18:50:53 +02:00
|
|
|
|
|
|
|
|
|
2013-09-29 01:08:15 +02:00
|
|
|
|
|
|
|
|
namespace {
|
2013-10-06 18:50:53 +02:00
|
|
|
TypeInfo<Subject> shall_build_a_Subject_instance;
|
2013-09-29 01:08:15 +02:00
|
|
|
}
|
|
|
|
|
|
2013-10-06 18:50:53 +02:00
|
|
|
/**
|
|
|
|
|
* instance of the singleton factory
|
|
|
|
|
* @note especially for this example we're using just \em one
|
|
|
|
|
* shared instance of the factory.
|
|
|
|
|
* Yet still, the two (inlined) calls to the get() function
|
|
|
|
|
* access different addresses for the embedded singleton instance
|
|
|
|
|
*/
|
|
|
|
|
AccessPoint fab(shall_build_a_Subject_instance);
|
2013-09-30 02:09:31 +02:00
|
|
|
|
2013-09-29 01:08:15 +02:00
|
|
|
|
2013-09-30 00:58:39 +02:00
|
|
|
Subject&
|
2013-09-29 01:08:15 +02:00
|
|
|
fabricate()
|
|
|
|
|
{
|
2013-10-06 17:37:01 +02:00
|
|
|
return fab.get();
|
2013-09-29 01:08:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-09-30 00:42:27 +02:00
|
|
|
} // namespace test
|