mirror of
https://github.com/geode-sdk/geode.git
synced 2025-03-25 04:11:42 -04:00
Merge branch 'main' into tulip-hook
This commit is contained in:
commit
1a51754e65
2 changed files with 48 additions and 16 deletions
loader/include/Geode
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <Geode/binding/GDString.hpp>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
|
@ -33,22 +34,50 @@ namespace gd {
|
|||
}
|
||||
|
||||
public:
|
||||
template <class... Params>
|
||||
string(Params&&... params) {
|
||||
m_data.m_pointer = 0;
|
||||
string() {
|
||||
m_data.m_storage[0] = 0;
|
||||
m_data.m_length = 0;
|
||||
m_data.m_capacity = 15;
|
||||
|
||||
auto val = std::string(std::forward<Params>(params)...);
|
||||
(void)this->winAssign(val.c_str(), val.size());
|
||||
}
|
||||
|
||||
string(string const& param) : string() {
|
||||
(void)this->winAssign(param.c_str(), param.size());
|
||||
}
|
||||
|
||||
string(string&& param) : string() {
|
||||
(void)this->winAssign(param.c_str(), param.size());
|
||||
}
|
||||
|
||||
string(char const* param) : string() {
|
||||
(void)this->winAssign(param, std::strlen(param));
|
||||
}
|
||||
|
||||
string(std::string const& param) : string() {
|
||||
(void)this->winAssign(param.c_str(), param.size());
|
||||
}
|
||||
|
||||
string& operator=(string const& param) {
|
||||
(void)this->winAssign(param.c_str(), param.size());
|
||||
return *this;
|
||||
}
|
||||
|
||||
string& operator=(string&& param) {
|
||||
(void)this->winAssign(param.c_str(), param.size());
|
||||
return *this;
|
||||
}
|
||||
|
||||
string& operator=(char const* param) {
|
||||
(void)this->winAssign(param, std::strlen(param));
|
||||
return *this;
|
||||
}
|
||||
|
||||
string& operator=(std::string const& param) {
|
||||
(void)this->winAssign(param.c_str(), param.size());
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class Param>
|
||||
string& operator=(Param&& param) {
|
||||
std::string val;
|
||||
val = std::forward<Param>(param);
|
||||
(void)this->winAssign(val.c_str(), val.size());
|
||||
return *this;
|
||||
void clear() {
|
||||
(void)this->winDtor();
|
||||
}
|
||||
|
||||
~string() {
|
||||
|
|
|
@ -31,6 +31,11 @@ namespace geode::utils {
|
|||
return new MiniFunctionState(*this);
|
||||
}
|
||||
};
|
||||
|
||||
template <class Callable, class Ret, class... Args>
|
||||
concept MiniFunctionCallable = requires(Callable&& func, Args... args) {
|
||||
{ func(args...) } -> std::same_as<Ret>;
|
||||
};
|
||||
|
||||
template <class Ret, class... Args>
|
||||
class MiniFunction<Ret(Args...)> {
|
||||
|
@ -56,9 +61,7 @@ namespace geode::utils {
|
|||
}
|
||||
|
||||
template <class Callable>
|
||||
requires requires(Callable&& func, Args... args) {
|
||||
{ func(args...) } -> std::same_as<Ret>;
|
||||
}
|
||||
requires(MiniFunctionCallable<Callable, Ret, Args...> && !std::is_same_v<std::decay_t<Callable>, MiniFunction<FunctionType>>)
|
||||
MiniFunction(Callable&& func) :
|
||||
m_state(new MiniFunctionState<std::decay_t<Callable>, Ret, Args...>(std::forward<Callable>(func))) {}
|
||||
|
||||
|
@ -83,4 +86,4 @@ namespace geode::utils {
|
|||
return m_state;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue