From 967be9e750221ab2ab783f95df79bb26d290a45e Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:07:58 +0200 Subject: add: added projects --- tiger-compiler/lib/misc/singleton.hh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tiger-compiler/lib/misc/singleton.hh (limited to 'tiger-compiler/lib/misc/singleton.hh') diff --git a/tiger-compiler/lib/misc/singleton.hh b/tiger-compiler/lib/misc/singleton.hh new file mode 100644 index 0000000..609136f --- /dev/null +++ b/tiger-compiler/lib/misc/singleton.hh @@ -0,0 +1,28 @@ +/** + ** \file misc/singleton.hh + ** \brief Generic singleton + */ + +#pragma once + +namespace misc +{ + template class Singleton + { + // FIXME DONE: Some code was deleted here. + protected: + Singleton() = default; + + private: + Singleton(const Singleton&) = delete; + Singleton& operator=(const Singleton&) = delete; + + public: + static T& instance() + { + static T instance_; + return instance_; + } + }; + +} // namespace misc -- cgit v1.2.3