bug fixesy
This commit is contained in:
+46
-17
@@ -39,10 +39,10 @@ T min(const VT<T>& v) {
|
||||
return min_v;
|
||||
}
|
||||
template<class T, template<typename ...> class VT>
|
||||
VT<T> mins(const VT<T>& arr) {
|
||||
const int& len = arr.size;
|
||||
decayed_t<VT,T> mins(const VT<T>& arr) {
|
||||
const uint32_t& len = arr.size;
|
||||
std::deque<std::pair<T, uint32_t>> cache;
|
||||
VT<T> ret(len);
|
||||
decayed_t<VT,T> ret(len);
|
||||
T min = std::numeric_limits<T>::max();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (arr[i] < min)
|
||||
@@ -52,9 +52,9 @@ VT<T> mins(const VT<T>& arr) {
|
||||
return ret;
|
||||
}
|
||||
template<class T, template<typename ...> class VT>
|
||||
VT<T> maxs(const VT<T>& arr) {
|
||||
const int& len = arr.size;
|
||||
VT<T> ret(len);
|
||||
decayed_t<VT,T> maxs(const VT<T>& arr) {
|
||||
const uint32_t& len = arr.size;
|
||||
decayed_t<VT,T> ret(len);
|
||||
T max = std::numeric_limits<T>::min();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (arr[i] > max)
|
||||
@@ -65,9 +65,9 @@ VT<T> maxs(const VT<T>& arr) {
|
||||
}
|
||||
|
||||
template<class T, template<typename ...> class VT>
|
||||
VT<T> minw(const VT<T>& arr, uint32_t w) {
|
||||
const int& len = arr.size;
|
||||
VT<T> ret(len);
|
||||
decayed_t<VT,T> minw(uint32_t w, const VT<T>& arr) {
|
||||
const uint32_t& len = arr.size;
|
||||
decayed_t<VT,T> ret{len};
|
||||
std::deque<std::pair<T, uint32_t>> cache;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (!cache.empty() && cache.front().second == i - w) cache.pop_front();
|
||||
@@ -79,9 +79,9 @@ VT<T> minw(const VT<T>& arr, uint32_t w) {
|
||||
}
|
||||
|
||||
template<class T, template<typename ...> class VT>
|
||||
VT<T> maxw(const VT<T>& arr, uint32_t w) {
|
||||
const int& len = arr.size;
|
||||
VT<T> ret(len);
|
||||
decayed_t<VT,T> maxw(uint32_t w, const VT<T>& arr) {
|
||||
const uint32_t& len = arr.size;
|
||||
decayed_t<VT, T> ret(len);
|
||||
std::deque<std::pair<T, uint32_t>> cache;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (!cache.empty() && cache.front().second == i - w) cache.pop_front();
|
||||
@@ -91,15 +91,44 @@ VT<T> maxw(const VT<T>& arr, uint32_t w) {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<class T, template<typename ...> class VT>
|
||||
decayed_t<VT, types::GetLongType<T>> sumw(uint32_t w, const VT<T>& arr) {
|
||||
const uint32_t& len = arr.size;
|
||||
decayed_t<VT, types::GetLongType<T>> ret(len);
|
||||
uint32_t i = 0;
|
||||
w = w > len ? len : w;
|
||||
if(arr.size)
|
||||
ret[i++] = arr[0];
|
||||
for (; i < w; ++i)
|
||||
ret[i] = ret[i-1] + arr[i];
|
||||
for (; i < len; ++i)
|
||||
ret[i] = ret[i-1] + arr[i] - arr[i-w];
|
||||
return ret;
|
||||
}
|
||||
template<class T, template<typename ...> class VT>
|
||||
decayed_t<VT, types::GetFPType<T>> avgw(uint32_t w, const VT<T>& arr) {
|
||||
typedef types::GetFPType<T> FPType;
|
||||
const uint32_t& len = arr.size;
|
||||
decayed_t<VT, FPType> ret(len);
|
||||
uint32_t i = 0;
|
||||
types::GetLongType<T> s;
|
||||
w = w > len ? len : w;
|
||||
if(arr.size)
|
||||
s = ret[i++] = arr[0];
|
||||
for (; i < w; ++i)
|
||||
ret[i] = (s += arr[i])/(FPType)(i+1);
|
||||
for (; i < len; ++i)
|
||||
ret[i] = ret[i-1] + (arr[i] - arr[i-w])/(FPType)w;
|
||||
return ret;
|
||||
}
|
||||
template <class T> constexpr inline T max(const T& v) { return v; }
|
||||
template <class T> constexpr inline T min(const T& v) { return v; }
|
||||
template <class T> constexpr inline T avg(const T& v) { return v; }
|
||||
template <class T> constexpr inline T sum(const T& v) { return v; }
|
||||
template <class T> constexpr inline T maxw(const T& v, uint32_t) { return v; }
|
||||
template <class T> constexpr inline T minw(const T& v, uint32_t) { return v; }
|
||||
template <class T> constexpr inline T avgw(const T& v, uint32_t) { return v; }
|
||||
template <class T> constexpr inline T sumw(const T& v, uint32_t) { return v; }
|
||||
template <class T> constexpr inline T maxw(uint32_t, const T& v) { return v; }
|
||||
template <class T> constexpr inline T minw(uint32_t, const T& v) { return v; }
|
||||
template <class T> constexpr inline T avgw(uint32_t, const T& v) { return v; }
|
||||
template <class T> constexpr inline T sumw(uint32_t, const T& v) { return v; }
|
||||
template <class T> constexpr inline T maxs(const T& v) { return v; }
|
||||
template <class T> constexpr inline T mins(const T& v) { return v; }
|
||||
template <class T> constexpr inline T avgs(const T& v) { return v; }
|
||||
|
||||
+5
-5
@@ -2,14 +2,14 @@
|
||||
#include "types.h"
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
template <class ...Types>
|
||||
std::string generate_printf_string(const char* sep = " ", const char* end = "\n") {
|
||||
std::string str;
|
||||
(void)std::initializer_list<int>{
|
||||
(str += types::printf_str[types::Types<Types>::getType()], str += sep, 0)...
|
||||
};
|
||||
((str += types::printf_str[types::Types<value_type_r<Types>>::getType()], str += sep), ...);
|
||||
const auto trim = str.size() - strlen(sep);
|
||||
if (trim > 0)
|
||||
str.resize(trim);
|
||||
str += end;
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ int _main()
|
||||
}
|
||||
dlclose(handle);
|
||||
}
|
||||
static_assert(std::is_same_v<decltype(fill_integer_array<5, 1>()), std::integer_sequence<bool, 1,1,1,1,1>>, "");
|
||||
//static_assert(std::is_same_v<decltype(fill_integer_array<5, 1>()), std::integer_sequence<bool, 1,1,1,1,1>>, "");
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -10,30 +10,48 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "server", "server.vcxproj",
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "msc-plugin", "..\msc-plugin\msc-plugin.vcxproj", "{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}"
|
||||
EndProject
|
||||
Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "msvs-py", "..\msvs-py\msvs-py.pyproj", "{CCC243F5-663E-45B7-A6DE-B2468C58B3A7}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.Debug|x64.Build.0 = Debug|x64
|
||||
{031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.Debug|x86.Build.0 = Debug|Win32
|
||||
{031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.Release|Any CPU.Build.0 = Release|x64
|
||||
{031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.Release|x64.ActiveCfg = Release|x64
|
||||
{031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.Release|x64.Build.0 = Release|x64
|
||||
{031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.Release|x86.ActiveCfg = Release|Win32
|
||||
{031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.Release|x86.Build.0 = Release|Win32
|
||||
{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.Debug|x64.Build.0 = Debug|x64
|
||||
{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.Debug|x86.Build.0 = Debug|Win32
|
||||
{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.Release|Any CPU.Build.0 = Release|x64
|
||||
{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.Release|x64.ActiveCfg = Release|x64
|
||||
{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.Release|x64.Build.0 = Release|x64
|
||||
{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.Release|x86.ActiveCfg = Release|Win32
|
||||
{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.Release|x86.Build.0 = Release|Win32
|
||||
{CCC243F5-663E-45B7-A6DE-B2468C58B3A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CCC243F5-663E-45B7-A6DE-B2468C58B3A7}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{CCC243F5-663E-45B7-A6DE-B2468C58B3A7}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{CCC243F5-663E-45B7-A6DE-B2468C58B3A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CCC243F5-663E-45B7-A6DE-B2468C58B3A7}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{CCC243F5-663E-45B7-A6DE-B2468C58B3A7}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -167,6 +167,7 @@
|
||||
<ClInclude Include="aggregations.h" />
|
||||
<ClInclude Include="gc.hpp" />
|
||||
<ClInclude Include="hasher.h" />
|
||||
<ClInclude Include="io.h" />
|
||||
<ClInclude Include="libaquery.h" />
|
||||
<ClInclude Include="priority_vector.hpp" />
|
||||
<ClInclude Include="table.h" />
|
||||
|
||||
+84
-1
@@ -6,6 +6,8 @@
|
||||
#include "types.h"
|
||||
#include "vector_type.hpp"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "io.h"
|
||||
template <typename T>
|
||||
class vector_type;
|
||||
template <>
|
||||
@@ -26,8 +28,10 @@ template<typename _Ty>
|
||||
class ColRef : public vector_type<_Ty>
|
||||
{
|
||||
public:
|
||||
typedef ColRef<_Ty> Decayed_t;
|
||||
const char* name;
|
||||
types::Type_t ty = types::ERROR;
|
||||
ColRef() : vector_type<_Ty>(0), name("") {}
|
||||
ColRef(const uint32_t& size, const char* name = "") : vector_type<_Ty>(size), name(name) {}
|
||||
ColRef(const char* name) : name(name) {}
|
||||
void init() { ty = types::Types<_Ty>::getType(); this->size = this->capacity = 0; this->container = 0; }
|
||||
@@ -37,6 +41,14 @@ public:
|
||||
ColView<_Ty> operator [](const vector_type<uint32_t>&idxs) const {
|
||||
return ColView<_Ty>(*this, idxs);
|
||||
}
|
||||
|
||||
void out(uint32_t n = 4, const char* sep = " ") const {
|
||||
n = n > this->size ? this->size : n;
|
||||
std::cout << '(';
|
||||
for (uint32_t i = 0; i < n; ++i)
|
||||
std::cout << this->operator[](i) << sep;
|
||||
std::cout << ')';
|
||||
}
|
||||
template<typename T>
|
||||
ColRef<T> scast();
|
||||
};
|
||||
@@ -44,6 +56,7 @@ public:
|
||||
template<typename _Ty>
|
||||
class ColView {
|
||||
public:
|
||||
typedef ColRef<_Ty> Decayed_t;
|
||||
const vector_type<uint32_t>& idxs;
|
||||
const ColRef<_Ty>& orig;
|
||||
const uint32_t& size;
|
||||
@@ -77,8 +90,22 @@ public:
|
||||
Iterator_t end() const {
|
||||
return Iterator_t(idxs.end(), orig);
|
||||
}
|
||||
void out(uint32_t n = 4, const char* sep = " ") const {
|
||||
n = n > size ? size : n;
|
||||
std::cout<<'(';
|
||||
for (uint32_t i = 0; i < n; ++i)
|
||||
std::cout << this->operator[](i)<< sep;
|
||||
std::cout << ')';
|
||||
}
|
||||
};
|
||||
|
||||
template <template <class...> class VT, class T>
|
||||
std::ostream& operator<<(std::ostream& os, const VT<T>& v)
|
||||
{
|
||||
v.out();
|
||||
return os;
|
||||
}
|
||||
template <class Type>
|
||||
struct decayed_impl<ColView, Type> { typedef ColRef<Type> type; };
|
||||
template<typename _Ty>
|
||||
template<typename T>
|
||||
inline ColRef<T> ColRef<_Ty>::scast()
|
||||
@@ -103,6 +130,17 @@ template <long long _Index, class... _Types>
|
||||
constexpr inline ColRef<std::tuple_element_t<_Index, std::tuple<_Types...>>>& get(const TableView<_Types...>& table) noexcept {
|
||||
return *(ColRef<std::tuple_element_t<_Index, std::tuple<_Types...>>> *) & (table.info.colrefs[_Index]);
|
||||
}
|
||||
template <class T>
|
||||
struct is_vector_impl : std::false_type {};
|
||||
template <class V>
|
||||
struct is_vector_impl<ColRef<V>> : std::true_type {};
|
||||
template <class V>
|
||||
struct is_vector_impl<ColView<V>> : std::true_type {};
|
||||
template <class V>
|
||||
struct is_vector_impl<vector_type<V>> : std::true_type {};
|
||||
template <class T>
|
||||
constexpr static bool is_vector_type = is_vector_impl<T>::value;
|
||||
|
||||
template<class ...Types>
|
||||
struct TableView;
|
||||
template<class ...Types>
|
||||
@@ -158,7 +196,49 @@ struct TableInfo {
|
||||
auto order_by_view () {
|
||||
return TableView<Types...>(order_by<cols...>(), *this);
|
||||
}
|
||||
template <int col, int ...rem_cols, class Fn, class ...__Types>
|
||||
inline void print2_impl(Fn func, const uint32_t& i, const __Types& ... args) const {
|
||||
using this_type = typename std::tuple_element<col, tuple_type>::type;
|
||||
const auto& this_value = get<col>(*this)[i];
|
||||
const auto& next = [&](auto &v) {
|
||||
if constexpr (sizeof...(rem_cols) == 0)
|
||||
func(args..., v);
|
||||
else
|
||||
print2_impl<rem_cols...>(func, i, args ..., v);
|
||||
};
|
||||
if constexpr (is_vector_type<this_type>)
|
||||
for (int j = 0; j < this_value.size; ++j)
|
||||
next(this_value[j]);
|
||||
else
|
||||
next(this_value);
|
||||
}
|
||||
template <int ...cols>
|
||||
void print2(const char* __restrict sep = ",", const char* __restrict end = "\n",
|
||||
const vector_type<uint32_t>* __restrict view = nullptr, FILE* __restrict fp = nullptr) const {
|
||||
std::string printf_string =
|
||||
generate_printf_string<typename std::tuple_element<cols, tuple_type>::type ...>(sep, end);
|
||||
const auto& prt_loop = [&fp, &view, &printf_string, *this](const auto& f) {
|
||||
if(view)
|
||||
for (int i = 0; i < view->size; ++i)
|
||||
print2_impl<cols...>(f, (*view)[i], printf_string.c_str());
|
||||
else
|
||||
for (int i = 0; i < colrefs[0].size; ++i)
|
||||
print2_impl<cols...>(f, i, printf_string.c_str());
|
||||
};
|
||||
if (fp)
|
||||
prt_loop([&fp](auto... args) { fprintf(fp, args...); });
|
||||
else
|
||||
prt_loop(printf);
|
||||
}
|
||||
template <int ...vals> struct applier {
|
||||
inline constexpr static void apply(const TableInfo<Types...>& t, const char* __restrict sep = ",", const char* __restrict end = "\n",
|
||||
const vector_type<uint32_t>* __restrict view = nullptr, FILE* __restrict fp = nullptr)
|
||||
{ t.template print2<vals ...>(sep, end, view, fp); }};
|
||||
|
||||
inline void printall(const char* __restrict sep = ",", const char* __restrict end = "\n",
|
||||
const vector_type<uint32_t>* __restrict view = nullptr, FILE* __restrict fp = nullptr) {
|
||||
applyIntegerSequence<sizeof...(Types), applier>::apply(*this, sep, end, view, fp);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -189,6 +269,9 @@ template <class T>
|
||||
constexpr static inline bool is_vector(const T&) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class ...Types>
|
||||
TableInfo<Types...>::TableInfo(const char* name, uint32_t n_cols) : name(name), n_cols(n_cols) {
|
||||
this->colrefs = (ColRef<void>*)malloc(sizeof(ColRef<void>) * n_cols);
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
#include "types.h"
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
//template<typename T>
|
||||
//inline static constexpr void types::Types<T>::print(T& v)
|
||||
//{
|
||||
// std::cout << v;
|
||||
//}
|
||||
#include <chrono>
|
||||
#include <ctime>
|
||||
namespace types {
|
||||
|
||||
+59
-10
@@ -14,8 +14,8 @@ namespace types {
|
||||
AINT, AFLOAT, ASTR, ADOUBLE, ALDOUBLE, ALONG, ASHORT, ADATE, ATIME, ACHAR,
|
||||
AUINT, AULONG, AUSHORT, AUCHAR, NONE, ERROR
|
||||
};
|
||||
static constexpr const char* printf_str[] = { "%d ", "%f ", "%s ", "%lf ", "%llf ", "%ld ", "%hi ", "%s ", "%s ", "%c ",
|
||||
"%u ", "%lu ", "%hu ", "%hhu ", "NULL " };
|
||||
static constexpr const char* printf_str[] = { "%d", "%f", "%s", "%lf", "%llf", "%ld", "%hi", "%s", "%s", "%c",
|
||||
"%u", "%lu", "%hu", "%hhu", "NULL" };
|
||||
// TODO: deal with data/time <=> str/uint conversion
|
||||
struct date_t {
|
||||
uint32_t val;
|
||||
@@ -77,13 +77,13 @@ namespace types {
|
||||
using type = Cond(__Eq(float), float, Cond(__Eq(double), double, long double));
|
||||
};
|
||||
template<class T>
|
||||
using GetFPType = typename GetFPTypeImpl<T>::type;
|
||||
using GetFPType = typename GetFPTypeImpl<typename std::decay<T>::type>::type;
|
||||
template<class T>
|
||||
struct GetLongTypeImpl {
|
||||
using type = Cond(_U(T), unsigned long long, Cond(Fp(T), long double, long long));
|
||||
};
|
||||
template<class T>
|
||||
using GetLongType = typename GetLongTypeImpl<T>::type;
|
||||
using GetLongType = typename GetLongTypeImpl<typename std::decay<T>::type>::type;
|
||||
}
|
||||
|
||||
#define getT(i, t) std::tuple_element_t<i, std::tuple<t...>>
|
||||
@@ -122,12 +122,61 @@ using decays = typename decayS<typename std::decay<T>::type>::type;
|
||||
template <class T>
|
||||
using decay_inner = typename decayS<T>::type;
|
||||
|
||||
template <int n, bool v = 1, bool ...vals>
|
||||
auto fill_integer_array() {
|
||||
if constexpr (n == 0)
|
||||
return std::integer_sequence<bool, vals...>{};
|
||||
else
|
||||
return fill_integer_array<n - 1, v, v, vals...>();
|
||||
template <class, template <class...> class T>
|
||||
struct instance_of_impl : std::false_type {};
|
||||
template <class ...T1, template <class ...> class T2>
|
||||
struct instance_of_impl<T2<T1...>, T2> : std::true_type {};
|
||||
|
||||
template <class T1, class T2>
|
||||
struct same_class_impl : std::false_type {};
|
||||
template <class ...T1s, class ...T2s, template <class...> class T1>
|
||||
struct same_class_impl<T1<T1s...>, T1<T2s...>> : std::true_type {};
|
||||
|
||||
template <class T1, class T2>
|
||||
bool same_class = same_class_impl<T1, T2>::value;
|
||||
template <class T1, template <class...> class T2>
|
||||
bool instance_of = instance_of_impl<T1, T2>::value;
|
||||
|
||||
template <class lT, template <typename ...> class rT>
|
||||
using transTypes = typename transTypes_s<lT, rT>::type;
|
||||
|
||||
template <class lT, class vT, template <vT ...> class rT>
|
||||
struct transValues_s;
|
||||
template <class vT, template<class, vT ...> class lT, vT ...T, template<vT ...> class rT>
|
||||
struct transValues_s<lT<vT, T...>, vT, rT> {
|
||||
using type = rT<T...>;
|
||||
};
|
||||
|
||||
#include <utility>
|
||||
template <class vT, int i, template <vT ...> class rT>
|
||||
using transValues = typename transValues_s<std::make_integer_sequence<vT, i>, vT, rT>::type;
|
||||
template <int i, template <int ...> class rT>
|
||||
using applyIntegerSequence = typename transValues_s<std::make_integer_sequence<int, i>, int, rT>::type;
|
||||
template <template <class ...> class T, class ...Types>
|
||||
struct decayed_impl{ typedef T<Types...> type;};
|
||||
template <template <typename ...> class VT, class ...Types>
|
||||
using decayed_t = typename decayed_impl<VT, Types...>::type;
|
||||
|
||||
template <class First = void, class...Rest>
|
||||
struct get_first_impl {
|
||||
typedef First first;
|
||||
constexpr static size_t rest_len = sizeof...(Rest);
|
||||
typedef get_first_impl<Rest...> rest;
|
||||
};
|
||||
template <class ...T>
|
||||
using get_first = typename get_first_impl<T...>::first;
|
||||
template <class T>
|
||||
struct value_type_impl { typedef T type; };
|
||||
template <template <class...> class VT, class ...V>
|
||||
struct value_type_impl<VT<V...>> { typedef get_first<V...> type; };
|
||||
template <class T>
|
||||
using value_type = typename value_type_impl<T>::type;
|
||||
template <class ...T>
|
||||
using get_first = typename get_first_impl<T...>::first;
|
||||
template <class T>
|
||||
struct value_type_rec_impl { typedef T type; };
|
||||
template <template <class...> class VT, class ...V>
|
||||
struct value_type_rec_impl<VT<V...>> { typedef typename value_type_rec_impl<get_first<int>>::type type; };
|
||||
template <class T>
|
||||
using value_type_r = typename value_type_rec_impl<T>::type;
|
||||
#endif // !_TYPES_H
|
||||
|
||||
@@ -1 +1,11 @@
|
||||
#include "vector_type.hpp"
|
||||
#include <iostream>
|
||||
template<typename _Ty>
|
||||
inline void vector_type<_Ty>::out(uint32_t n, const char* sep) const
|
||||
{
|
||||
n = n > size ? size : n;
|
||||
std::cout << '(';
|
||||
for (uint32_t i = 0; i < n; ++i)
|
||||
std::cout << this->operator[](i) << sep;
|
||||
std::cout << ')';
|
||||
}
|
||||
@@ -22,7 +22,11 @@
|
||||
template <typename _Ty>
|
||||
class vector_type {
|
||||
public:
|
||||
typedef vector_type<_Ty> Decayed_t;
|
||||
void inline _copy(const vector_type<_Ty>& vt) {
|
||||
// quick init while using malloc
|
||||
//if (capacity > 0) free(container);
|
||||
|
||||
this->size = vt.size;
|
||||
this->capacity = vt.capacity;
|
||||
this->container = (_Ty*)malloc(size * sizeof(_Ty));
|
||||
@@ -54,10 +58,10 @@ public:
|
||||
}
|
||||
}
|
||||
constexpr vector_type() noexcept : size(0), capacity(0), container(0) {};
|
||||
constexpr vector_type(const vector_type<_Ty>& vt) noexcept {
|
||||
constexpr vector_type(const vector_type<_Ty>& vt) noexcept : capacity(0) {
|
||||
_copy(vt);
|
||||
}
|
||||
constexpr vector_type(vector_type<_Ty>&& vt) noexcept {
|
||||
constexpr vector_type(vector_type<_Ty>&& vt) noexcept : capacity(0) {
|
||||
_move(std::move(vt));
|
||||
}
|
||||
vector_type<_Ty> operator =(const _Ty& vt) {
|
||||
@@ -179,6 +183,7 @@ public:
|
||||
}
|
||||
size = this->size + dist;
|
||||
}
|
||||
void out(uint32_t n = 4, const char* sep = " ") const;
|
||||
~vector_type() {
|
||||
if (capacity > 0) free(container);
|
||||
container = 0; size = capacity = 0;
|
||||
@@ -250,7 +255,7 @@ public:
|
||||
}
|
||||
}
|
||||
constexpr vector_type() : size(0), capacity(0), container(0) {};
|
||||
void *get(uint32_t i, types::Type_t atype){
|
||||
void* get(uint32_t i, types::Type_t atype){
|
||||
return static_cast<void*>(static_cast<char*>(container) + (i * types::AType_sizes[atype]));
|
||||
}
|
||||
void operator[](const uint32_t& i) {
|
||||
|
||||
Reference in New Issue
Block a user