LeviLamina
Loading...
Searching...
No Matches
NewType.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5template <typename T0>
6struct NewType {
7public:
8 T0 mValue;
9
10 [[nodiscard]] NewType() : mValue{} {}
11
12 [[nodiscard]] NewType(T0 const& t) : mValue{t} {}
13
14 // not trivially copyable
15 [[nodiscard]] NewType(NewType const& other) : mValue{other.mValue} {}
16
17 NewType& operator=(NewType const& other) {
18 mValue = other.mValue;
19 return *this;
20 }
21 [[nodiscard]] bool operator==(NewType const& other) const
22 requires(requires { mValue == other.mValue; })
23 {
24 return mValue == other.mValue;
25 }
26 [[nodiscard]] bool operator==(T0 const& other) const
27 requires(requires { mValue == other; })
28 {
29 return mValue == other;
30 }
31};
32
33namespace std {
34template <class T>
35class hash<NewType<T>> {
36public:
37 size_t operator()(NewType<T> const& t) const { return std::hash<T>{}(t.mValue); }
38};
39} // namespace std
STL namespace.
Definition NewType.h:6