CeresEngine
0.2.0
A game development framework
Loading...
Searching...
No Matches
StrongTypedef.hpp
Go to the documentation of this file.
1
//
2
// CeresEngine - A game development framework
3
//
4
// Created by Rogiel Sulzbach.
5
// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6
//
7
8
#pragma once
9
11
#define CE_STRONG_TYPEDEF(mUnderlying, mName) \
12
class mName final { \
13
private: \
14
mUnderlying value; \
15
\
16
public: \
17
inline mName() = default; \
18
inline mName(const mName& mX) = default; \
19
inline mName(mName&& mX) = default; \
20
inline mName& operator=(const mName& rhs) = default; \
21
inline mName& operator=(mName&& rhs) = default; \
22
inline constexpr explicit mName(mUnderlying mX) noexcept : value{mX} {} \
23
inline constexpr mName& operator=(mUnderlying rhs) noexcept { \
24
value = rhs; \
25
return *this; \
26
} \
27
inline constexpr operator const mUnderlying&() const noexcept { return value; } \
28
inline constexpr operator mUnderlying&() noexcept { return value; } \
29
inline constexpr decltype(auto) operator==(const mName& rhs) noexcept { return value == rhs.value; } \
30
inline constexpr decltype(auto) operator!=(const mName& rhs) noexcept { return value != rhs.value; } \
31
inline constexpr decltype(auto) operator<(const mName& rhs) noexcept { return value < rhs.value; } \
32
inline constexpr decltype(auto) operator>(const mName& rhs) noexcept { return value > rhs.value; } \
33
inline constexpr decltype(auto) operator<=(const mName& rhs) noexcept { return value <= rhs.value; } \
34
inline constexpr decltype(auto) operator>=(const mName& rhs) noexcept { return value >= rhs.value; } \
35
}; \
36
\
37
static_assert(std::is_literal_type<mName>{})
Sources
CeresEngine
Foundation
MPL
StrongTypedef.hpp
Generated by
1.9.8