cymoca
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
util.h
Go to the documentation of this file.
1 #ifndef CYMOCA_UTIL_H_
2 #define CYMOCA_UTIL_H_
3 
4 #include <memory>
5 
6 template <typename Derived, typename Base>
7 std::unique_ptr<Derived> static_unique_ptr_cast(std::unique_ptr<Base> &&p) {
8  auto d = static_cast<Derived *>(p.release());
9  assert(d);
10  return std::unique_ptr<Derived>(d);
11 }
12 
13 struct EnumClassHash {
14  template <typename T>
15  size_t operator()(T t) const {
16  return static_cast<size_t>(t);
17  }
18 };
19 
20 #endif
size_t operator()(T t) const
Definition: util.h:15
std::unique_ptr< Derived > static_unique_ptr_cast(std::unique_ptr< Base > &&p)
Definition: util.h:7