Initial commit
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
//
|
||||
// Created by darman on 9/5/26.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <format>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/type_index.hpp>
|
||||
|
||||
using string = std::string;
|
||||
|
||||
// Type aliases
|
||||
using int8 = int8_t;
|
||||
using int16 = int16_t;
|
||||
using int32 = int32_t;
|
||||
using int64 = int64_t;
|
||||
|
||||
using uint8 = uint8_t;
|
||||
using uint16 = uint16_t;
|
||||
using uint32 = uint32_t;
|
||||
using uint64 = uint64_t;
|
||||
|
||||
template <typename T> using Vector = std::vector<T>;
|
||||
template <typename T> using Set = std::unordered_set<T>;
|
||||
template <typename K, typename V> using Map = std::unordered_map<K, V>;
|
||||
template <typename T> using Optional = std::optional<T>;
|
||||
constexpr std::nullopt_t None = std::nullopt;
|
||||
|
||||
template <typename T> using Ref = std::shared_ptr<T>;
|
||||
template <typename T, typename... Args> constexpr Ref<T> MakeRef(Args&&... args)
|
||||
{
|
||||
return std::make_shared<T>(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename T, typename D = std::default_delete<T>> constexpr Ref<T> MakeRef(T* ptr, D deleter = D())
|
||||
{
|
||||
return Ref<T>(ptr, std::move(deleter));
|
||||
}
|
||||
|
||||
template <typename T, typename D = std::default_delete<T>> using UniqueRef = std::unique_ptr<T, D>;
|
||||
template <typename T, typename D = std::default_delete<T>, typename... Args>
|
||||
constexpr UniqueRef<T, D> MakeUniqueRef(Args&&... args)
|
||||
{
|
||||
return std::make_unique<T, D>(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename T> constexpr string TypeName()
|
||||
{
|
||||
return boost::typeindex::type_id<T>().pretty_name();
|
||||
}
|
||||
Reference in New Issue
Block a user