Skip to content

Commit e15469b

Browse files
committed
Linux compilation no. 2
1 parent 0fa2b44 commit e15469b

4 files changed

Lines changed: 31 additions & 8 deletions

File tree

plugins/src/natives/iter.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,24 @@
77
//#include <deque>
88
#include <type_traits>
99

10+
#ifndef _DEBUG
11+
#ifdef _WIN32
1012
template <class Type>
1113
struct is_simple
1214
{
1315
static constexpr const bool value = sizeof(Type) == sizeof(cell) && std::is_trivially_assignable<Type, Type>::value && std::is_trivially_destructible<Type>::value;
1416
};
15-
17+
#else
1618
template <class Type>
17-
constexpr const bool is_simple_v = is_simple<Type>::value;
19+
struct is_simple
20+
{
21+
static constexpr const bool value = sizeof(Type) == sizeof(cell);
22+
};
23+
#endif
1824

1925
// Iterators fit inside a single cell, but not in debug in VC++.
20-
#ifndef _DEBUG
21-
static_assert(is_simple_v<std::vector<dyn_object>::iterator>, "Vector is not simple.");
22-
static_assert(is_simple_v<std::unordered_map<dyn_object, dyn_object>::iterator>, "Map is not simple.");
26+
static_assert(is_simple<std::vector<dyn_object>::iterator>::value, "Vector is not simple.");
27+
static_assert(is_simple<std::unordered_map<dyn_object, dyn_object>::iterator>::value, "Map is not simple.");
2328
//static_assert(is_simple_v<std::unordered_set<dyn_object>::iterator>, "Set is not simple.");
2429
#endif
2530

plugins/src/natives/map.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class key_at
1919

2020
public:
2121
// native bool:map_add(Map:map, key, value, ...);
22-
template <key_ftype KeyFactory, typename value_ftype ValueFactory>
22+
template <key_ftype KeyFactory, value_ftype ValueFactory>
2323
static cell AMX_NATIVE_CALL map_add(AMX *amx, cell *params)
2424
{
2525
auto ptr = reinterpret_cast<map_t*>(params[1]);
@@ -29,7 +29,7 @@ class key_at
2929
}
3030

3131
// native bool:map_set(Map:map, key, value, ...);
32-
template <key_ftype KeyFactory, typename value_ftype ValueFactory>
32+
template <key_ftype KeyFactory, value_ftype ValueFactory>
3333
static cell AMX_NATIVE_CALL map_set(AMX *amx, cell *params)
3434
{
3535
auto ptr = reinterpret_cast<map_t*>(params[1]);
@@ -39,7 +39,7 @@ class key_at
3939
}
4040

4141
// native map_get(Map:map, key, ...);
42-
template <key_ftype KeyFactory, typename result_ftype ValueFactory>
42+
template <key_ftype KeyFactory, result_ftype ValueFactory>
4343
static cell AMX_NATIVE_CALL map_get(AMX *amx, cell *params)
4444
{
4545
auto ptr = reinterpret_cast<map_t*>(params[1]);

plugins/src/utils/dyn_object.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,23 @@ inline void hash_combine(size_t& seed, const T& v)
245245
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
246246
}
247247

248+
namespace std
249+
{
250+
template<>
251+
struct hash<cell_string>
252+
{
253+
size_t operator()(const cell_string &obj) const
254+
{
255+
size_t seed = 0;
256+
for(size_t i = 0; i < obj.size(); i++)
257+
{
258+
hash_combine(seed, obj[i]);
259+
}
260+
return seed;
261+
}
262+
};
263+
}
264+
248265
template <class TagType>
249266
bool dyn_object::get_hash_tagged(size_t &result) const
250267
{

plugins/src/utils/dyn_op.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "dyn_op.h"
2+
#include <cmath>
23

34
cell op_add<cell>::operator()(cell a, cell b) const
45
{

0 commit comments

Comments
 (0)