File: EnumPythonParser.h

package info (click to toggle)
freeorion 0.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 194,940 kB
  • sloc: cpp: 186,508; python: 40,969; ansic: 1,164; xml: 719; makefile: 32; sh: 7
file content (28 lines) | stat: -rw-r--r-- 567 bytes parent folder | download
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
#ifndef _EnumPythonParser_h
#define _EnumPythonParser_h

#include <functional>

namespace boost::python {
    class dict;
}

template<typename E>
struct enum_wrapper {
    enum_wrapper(E value_) : value(value_) { }

    const E value;

    auto operator<=>(const enum_wrapper<E>&) const = default;
};

template<typename E>
struct std::hash<enum_wrapper<E>> {
    std::size_t operator()(const enum_wrapper<E>& e) const noexcept {
        return std::hash<E>{}(e.value);
    }
};

void RegisterGlobalsEnums(boost::python::dict& globals);

#endif // _EnumPythonParser_h