表格线识别通用库文档
载入中...
搜索中...
未找到
type.h
浏览该文件的文档.
1/*
2 * @Description: 类型别名头文件
3 * @Version:
4 * @Autor: dreamy-xay
5 * @date: 2023-12-05
6 * @LastEditors: dreamy-xay
7 * @LastEditTime: 2024-05-09
8 */
9
10#ifndef COMMON_TYPE_H
11#define COMMON_TYPE_H
12
13#include <exception>
14#include <string>
15#include <numeric>
16
17namespace cm {
18
20using size_t = unsigned int;
22using uint = unsigned int;
24using byte = unsigned char;
26using uchar = unsigned char;
28using ushort = unsigned short;
30using ulong = unsigned long;
31
39class Exception : public std::exception {
40 private:
42 std::string exception_info;
43
44 public:
70 Exception(const std::string& exception_info) : exception_info(exception_info) {}
71
91 const char* what() const noexcept override {
92 return exception_info.c_str();
93 }
94};
95
105template <typename T>
106struct EnumHash {
140 std::size_t operator()(const T& value) const {
141 return std::hash<int>()(static_cast<int>(value));
142 }
143};
144
157template <typename T, typename U>
193 U operator()(const T& type) const {
194 return static_cast<U>(type);
195 }
196};
197
198} // namespace cm
199
200#endif
通用异常类
Definition type.h:39
Exception(const std::string &exception_info)
通用异常类的构造函数
Definition type.h:70
const char * what() const noexcept override
获取异常的描述信息
Definition type.h:91
点类
Definition point.hpp:52
unsigned int uint
无符号整型
Definition type.h:22
unsigned short ushort
无符号短整型
Definition type.h:28
unsigned int size_t
表示内存中对象的大小,经常用于表示数组长度、内存分配等涉及到大小的地方。
Definition type.h:20
unsigned char byte
字节类型
Definition type.h:24
隐式类型转换仿函数
Definition type.h:158
U operator()(const T &type) const
隐式类型转换仿函数重载括号运算符
Definition type.h:193
枚举哈希仿函数
Definition type.h:106
std::size_t operator()(const T &value) const
枚举哈希仿函数重载括号运算符
Definition type.h:140