dune-common 2.8.0
Loading...
Searching...
No Matches
singleton.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_SINGLETON_HH
4#define DUNE_SINGLETON_HH
5
7
15namespace Dune
16{
52 template<class T>
54 {
55 protected:
56 /* @brief Protected constructor. */
57 Singleton() = default;
58
59 public:
60
61 Singleton(const Singleton&) = delete;
62 void operator=(const Singleton&) = delete;
63
69 {
70 static T instance_;
71 return instance_;
72 }
73 };
74
75} // namespace Dune
76
77#endif
Definition of macros controlling symbol visibility at the ABI level.
#define DUNE_EXPORT
Export a symbol as part of the public ABI.
Definition visibility.hh:18
Dune namespace.
Definition alignedallocator.hh:11
An adapter to turn a class into a singleton.
Definition singleton.hh:54
Singleton()=default
Singleton(const Singleton &)=delete
void operator=(const Singleton &)=delete
static DUNE_EXPORT T & instance()
Get the instance of the singleton.
Definition singleton.hh:68