summaryrefslogtreecommitdiff
path: root/tiger-compiler/lib/misc/singleton.hh
blob: 609136ff1e519358115c34892149809e8c476bee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
 ** \file misc/singleton.hh
 ** \brief Generic singleton
 */

#pragma once

namespace misc
{
  template <typename T> class Singleton
  {
    // FIXME DONE: Some code was deleted here.
  protected:
    Singleton() = default;

  private:
    Singleton(const Singleton<T>&) = delete;
    Singleton& operator=(const Singleton<T>&) = delete;

  public:
    static T& instance()
    {
      static T instance_;
      return instance_;
    }
  };

} // namespace misc