Skip to content

Commit

Permalink
Singelton for stateless classes with more constness.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjansche committed Apr 6, 2016
1 parent 78c853a commit 4b9fde2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions festus/value-weight-singleton.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ struct DefaultInstance {
template <class S>
const S *const DefaultInstance<S>::kInstance = new S();

template <class S>
struct DefaultStaticInstance {
static constexpr S kStaticInstance = {};
static constexpr const S &Instance() { return kStaticInstance; }
};

template <class S>
constexpr S DefaultStaticInstance<S>::kStaticInstance;

// OpenFst weight façade for semirings whose elements are passed by value.
//
// This version works with a semiring class S with const member functions and
Expand Down

0 comments on commit 4b9fde2

Please sign in to comment.