Форум программистов, компьютерный форум, киберфорум
С++ для начинающих
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.60/5: Рейтинг темы: голосов - 5, средняя оценка - 4.60
3 / 3 / 0
Регистрация: 01.11.2012
Сообщений: 803

Неоднозначный вызов перегруженной функции

21.05.2018, 14:26. Показов 994. Ответов 12
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
Code
1
Ошибка    1   error C2668: hash_helper::hash: неоднозначный вызов перегруженной функции (C:\Users\Admin\Desktop\One\src\modules\Eluna\BattleGroundHooks.cpp)    c:\users\admin\desktop\one\src\modules\eluna\BindingMap.h   367 1   LuaEngine

Ругается на эту часть кода. что не так ??

C++
1
2
3
4
5
6
7
8
9
10
   template<typename T>
    struct hash < EventKey<T> >
    {
        typedef EventKey<T> argument_type;
 
        hash_helper::result_type operator()(argument_type const& k) const
        {
           return hash_helper::hash(k.event_id);
        }
    };
0
Programming
Эксперт
39485 / 9562 / 3019
Регистрация: 12.04.2006
Сообщений: 41,671
Блог
21.05.2018, 14:26
Ответы с готовыми решениями:

Неоднозначный вызов перегруженной функции
Ввести с клавиатуры число n. Динамически выделить память для массива целых чисел размером n. Заполнить массив данными с клавиатуры....

Неоднозначный вызов перегруженной функции
#include &quot;stdafx.h&quot; #include &lt;cstdlib&gt; #include &lt;iostream&gt; #include &lt;math.h&gt; #include &lt;Windows.h&gt; #include &lt;iomanip&gt; #include...

Pow: неоднозначный вызов перегруженной функции
#include &quot;stdafx.h&quot; #include &lt;iostream&gt; #include &lt;math.h&gt; #include &lt;conio.h&gt; #include &lt;string.h&gt; #define eps 10E-3 using...

12
475 / 427 / 290
Регистрация: 10.03.2015
Сообщений: 1,782
21.05.2018, 14:36
C++
1
return hash_helper::hash(k.event_id);
Скорее всего надо так:
C++
1
return hash_helper::hash<T>(k.event_id);
0
3 / 3 / 0
Регистрация: 01.11.2012
Сообщений: 803
21.05.2018, 14:40  [ТС]
нет. не помогло


C++
1
2
3
4
5
6
7
8
9
10
11
12
13
    template<typename T>
    struct hash < EventKey<T> >
    {
        typedef EventKey<T> argument_type;
 
        hash_helper::result_type operator()(argument_type const& k) const
        {
           //return hash_helper::hash(k.event_id);
           return hash_helper::hash<T>(k.event_id);
 
 
        }
    };
0
475 / 427 / 290
Регистрация: 10.03.2015
Сообщений: 1,782
21.05.2018, 14:42
Тогда показывай как вызываешь
0
3 / 3 / 0
Регистрация: 01.11.2012
Сообщений: 803
21.05.2018, 14:47  [ТС]
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
/*
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
* This program is free software licensed under GPL version 3
* Please see the included DOCS/LICENSE.md for more information
*/
 
#ifndef _BINDING_MAP_H
#define _BINDING_MAP_H
 
#include <memory>
#include "Common.h"
#include "ElunaUtility.h"
#include <type_traits>
 
extern "C"
{
#include "lua.h"
#include "lauxlib.h"
};
 
 
/*
 * A set of bindings from keys of type `K` to Lua references.
 */
template<typename K>
class BindingMap : public ElunaUtil::Lockable
{
private:
    lua_State* L;
    uint64 maxBindingID;
 
    struct Binding
    {
        uint64 id;
        lua_State* L;
        uint32 remainingShots;
        int functionReference;
 
        Binding(lua_State* L, uint64 id, int functionReference, uint32 remainingShots) :
            id(id),
            L(L),
            remainingShots(remainingShots),
            functionReference(functionReference)
        { }
 
        ~Binding()
        {
            luaL_unref(L, LUA_REGISTRYINDEX, functionReference);
        }
    };
 
    typedef std::vector< std::unique_ptr<Binding> > BindingList;
 
    std::unordered_map<K, BindingList> bindings;
    /*
     * This table is for fast removal of bindings by ID.
     *
     * Instead of having to look through (potentially) every BindingList to find
     *   the Binding with the right ID, this allows you to go directly to the
     *   BindingList that might have the Binding with that ID.
     *
     * However, you must be careful not to store pointers to BindingLists
     *   that no longer exist (see `void Clear(const K& key)` implementation).
     */
    std::unordered_map<uint64, BindingList*> id_lookup_table;
 
public:
    BindingMap(lua_State* L) :
        L(L),
        maxBindingID(0)
    { }
 
    /*
     * Insert a new binding from `key` to `ref`, which lasts for `shots`-many pushes.
     *
     * If `shots` is 0, it will never automatically expire, but can still be
     *   removed with `Clear` or `Remove`.
     */
    uint64 Insert(const K& key, int ref, uint32 shots)
    {
        Guard guard(GetLock());
 
        uint64 id = (++maxBindingID);
        BindingList& list = bindings[key];
        list.push_back(std::unique_ptr<Binding>(new Binding(L, id, ref, shots)));
        id_lookup_table[id] = &list;
        return id;
    }
 
    /*
     * Clear all bindings for `key`.
     */
    void Clear(const K& key)
    {
        Guard guard(GetLock());
 
        if (bindings.empty())
            return;
 
        auto iter = bindings.find(key);
        if (iter == bindings.end())
            return;
 
        BindingList& list = iter->second;
 
        // Remove all pointers to `list` from `id_lookup_table`.
        for (auto i = list.begin(); i != list.end(); ++i)
        {
            std::unique_ptr<Binding>& binding = *i;
            id_lookup_table.erase(binding->id);
        }
 
        bindings.erase(key);
    }
 
    /*
     * Clear all bindings for all keys.
     */
    void Clear()
    {
        Guard guard(GetLock());
 
        if (bindings.empty())
            return;
 
        id_lookup_table.clear();
        bindings.clear();
    }
 
    /*
     * Remove a specific binding identified by `id`.
     *
     * If `id` in invalid, nothing is removed.
     */
    void Remove(uint64 id)
    {
        Guard guard(GetLock());
 
        auto iter = id_lookup_table.find(id);
        if (iter == id_lookup_table.end())
            return;
 
        BindingList* list = iter->second;
        auto i = list->begin();
 
        for (; i != list->end(); ++i)
        {
            std::unique_ptr<Binding>& binding = *i;
            if (binding->id == id)
                break;
        }
 
        if (i != list->end())
            list->erase(i);
 
        // Unconditionally erase the ID in the lookup table because
        //   it was either already invalid, or it's no longer valid.
        id_lookup_table.erase(id);
    }
 
    /*
     * Check whether `key` has any bindings.
     */
    bool HasBindingsFor(const K& key)
    {
        Guard guard(GetLock());
 
        if (bindings.empty())
            return false;
 
        auto result = bindings.find(key);
        if (result == bindings.end())
            return false;
 
        BindingList& list = result->second;
        return !list.empty();
    }
 
    /*
     * Push all Lua references for `key` onto the stack.
     */
    void PushRefsFor(const K& key)
    {
        Guard guard(GetLock());
 
        if (bindings.empty())
            return;
 
        auto result = bindings.find(key);
        if (result == bindings.end())
            return;
 
        BindingList& list = result->second;
        for (auto i = list.begin(); i != list.end();)
        {
            std::unique_ptr<Binding>& binding = (*i);
            auto i_prev = (i++);
 
            lua_rawgeti(L, LUA_REGISTRYINDEX, binding->functionReference);
 
            if (binding->remainingShots > 0)
            {
                binding->remainingShots -= 1;
 
                if (binding->remainingShots == 0)
                {
                    id_lookup_table.erase(binding->id);
                    list.erase(i_prev);
                }
            }
        }
    }
};
 
 
/*
 * A `BindingMap` key type for simple event ID bindings
 *   (ServerEvents, GuildEvents, etc.).
 */
template <typename T>
struct EventKey
{
    T event_id;
 
    EventKey(T event_id) :
        event_id(event_id)
    { }
};
 
/*
 * A `BindingMap` key type for event ID/Object entry ID bindings
 *   (CreatureEvents, GameObjectEvents, etc.).
 */
template <typename T>
struct EntryKey
{
    T event_id;
    uint32 entry;
 
    EntryKey(T event_id, uint32 entry) :
        event_id(event_id),
        entry(entry)
    { }
};
 
/*
 * A `BindingMap` key type for event ID/unique Object bindings
 *   (currently just CreatureEvents).
 */
template <typename T>
struct UniqueObjectKey
{
    T event_id;
    uint64 guid;
    uint32 instance_id;
 
    UniqueObjectKey(T event_id, uint64 guid, uint32 instance_id) :
        event_id(event_id),
        guid(guid),
        instance_id(instance_id)
    { }
};
 
class hash_helper
{
public:
    typedef std::size_t result_type;
 
    template <typename T>
    static inline result_type hash(T const & t)
    {
        result_type seed = 0;
        _hash_combine(seed, t);
        return seed;
    }
 
 
 
 
    /*
    template <typename T, typename std::enable_if<std::is_enum<T>::value>::type* = nullptr>
    static inline result_type hash(T const & t)
    {
        return std::hash<typename std::underlying_type<T>::type>()(t);
    }
    
    template <typename T, typename std::enable_if<!std::is_enum<T>::value>::type* = nullptr>
    static inline result_type hash(T const & t)
    {
        return std::hash<T>()(t);
    }
 
    */
 
 
 
    template <typename T>
    static inline result_type hash(T const & t, typename std::enable_if<std::is_enum<T>::value>::type * = nullptr)
    {
       return std::hash<typename std::underlying_type<T>::type>()(t);
    }
    
    template <typename T>
    static inline result_type hash(T const & t, typename std::enable_if<!std::is_enum<T>::value>::type * = nullptr)
    {
        return std::hash<T>()(t);
    }
 
 
 
 
 
 
private:
    template <typename T>
    static inline void _hash_combine(result_type& seed, T const & v)
    {
        // from http://www.boost.org/doc/libs/1_40_0/boost/functional/hash/hash.hpp
        seed ^= hash(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
    }
 
    template <typename H, typename T>
    static inline void _hash_combine(result_type& seed, H const & h, T const & t)
    {
        _hash_combine(seed, h);
        _hash_combine(seed, t);
    }
};
 
/*
 * Implementations of various std functions on the above key types,
 *   so that they can be used within an unordered_map.
 */
namespace std
{
    template<typename T>
    struct equal_to < EventKey<T> >
    {
        bool operator()(EventKey<T> const& lhs, EventKey<T> const& rhs) const
        {
            return lhs.event_id == rhs.event_id;
        }
    };
 
    template<typename T>
    struct equal_to < EntryKey<T> >
    {
        bool operator()(EntryKey<T> const& lhs, EntryKey<T> const& rhs) const
        {
            return lhs.event_id == rhs.event_id
                && lhs.entry == rhs.entry;
        }
    };
 
    template<typename T>
    struct equal_to < UniqueObjectKey<T> >
    {
        bool operator()(UniqueObjectKey<T> const& lhs, UniqueObjectKey<T> const& rhs) const
        {
            return lhs.event_id == rhs.event_id
                && lhs.guid == rhs.guid
                && lhs.instance_id == rhs.instance_id;
        }
    };
 
    template<typename T>
    struct hash < EventKey<T> >
    {
        typedef EventKey<T> argument_type;
 
        hash_helper::result_type operator()(argument_type const& k) const
        {
           return hash_helper::hash(k.event_id);
        }
    };
 
    template<typename T>
    struct hash < EntryKey<T> >
    {
        typedef EntryKey<T> argument_type;
 
        hash_helper::result_type operator()(argument_type const& k) const
        {
         return hash_helper::hash(k.event_id, k.entry);
        }
    };
 
    template<typename T>
    struct hash < UniqueObjectKey<T> >
    {
        typedef UniqueObjectKey<T> argument_type;
 
        hash_helper::result_type operator()(argument_type const& k) const
        {
          return hash_helper::hash(k.event_id, k.instance_id, k.guid);
        }
    };
}
 
#endif // _BINDING_MAP_H
Вот весь файл целиком
0
475 / 427 / 290
Регистрация: 10.03.2015
Сообщений: 1,782
21.05.2018, 15:08
C++
1
2
3
4
5
template <typename T>
class hash_helper
{
public:
...
0
3 / 3 / 0
Регистрация: 01.11.2012
Сообщений: 803
21.05.2018, 15:13  [ТС]
сейчас проверю

Добавлено через 2 минуты
Теперь другая ошибка:

Ошибка 1 error C2955: hash_helper: для использования класса шаблон требуется список аргументов шаблон (C:\Users\Admin\Desktop\One\src\modules\ Eluna\BattleGroundHooks.cpp) c:\users\admin\desktop\one\src\modules\e luna\BindingMap.h 371 1 LuaEngine


C++
1
2
3
4
5
6
7
8
9
10
   template<typename T>
    struct hash < EventKey<T> >
    {
        typedef EventKey<T> argument_type;
 
        hash_helper::result_type operator()(argument_type const& k) const
        {
           return hash_helper::hash(k.event_id);
        }
    };
0
475 / 427 / 290
Регистрация: 10.03.2015
Сообщений: 1,782
21.05.2018, 15:23
Ну..
C++
1
2
hash_helper<T>::result_type
return hash_helper::hash<T>(k.event_id);
0
3 / 3 / 0
Регистрация: 01.11.2012
Сообщений: 803
21.05.2018, 15:29  [ТС]
ну я пробовал это

Code
1
Ошибка    2   error C2143: синтаксическая ошибка: отсутствие ";" перед "(" (C:\Users\Admin\Desktop\One\src\modules\Eluna\BattleGroundHooks.cpp)    c:\users\admin\desktop\one\src\modules\eluna\BindingMap.h   371 1   LuaEngine

C++
1
2
3
4
5
6
7
8
9
10
    template<typename T>
    struct hash < EventKey<T> >
    {
        typedef EventKey<T> argument_type;
 
        hash_helper<T>::result_type operator()(argument_type const& k) const
        {
           return hash_helper::hash<T>(k.event_id);
        }
    };
0
475 / 427 / 290
Регистрация: 10.03.2015
Сообщений: 1,782
21.05.2018, 15:38
А всё, там внутри класса темплейты стоят. Не надо так как я сказал делать.
0
3 / 3 / 0
Регистрация: 01.11.2012
Сообщений: 803
21.05.2018, 15:39  [ТС]
а как нужно делать ?? очень важно для меня это. Уж Прошу помощи
0
475 / 427 / 290
Регистрация: 10.03.2015
Сообщений: 1,782
21.05.2018, 15:44
Bookkc1, Ну, например не добавлять себе проблем и оставить так, как автор это сделал.
А как делать - на вскидку теперь уже не скажу.
0
3 / 3 / 0
Регистрация: 01.11.2012
Сообщений: 803
21.05.2018, 15:45  [ТС]
да дело в другом. не получается оставить как автор сделал...
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
inter-admin
Эксперт
29715 / 6470 / 2152
Регистрация: 06.03.2009
Сообщений: 28,500
Блог
21.05.2018, 15:45
Помогаю со студенческими работами здесь

Pow: неоднозначный вызов перегруженной функции
Помогите решить проблему: double HHDistrib::MX(int power) { double M = 0; for (int m = qMax(0, this-&gt;M + n - N), i = 0; i...

Ошибка: неоднозначный вызов перегруженной функции
Ошибка:= error C2668: TCalc::TCalc: неоднозначный вызов перегруженной функции myclass\myclass.cpp MyClass TCalc.cpp #include...

неоднозначный вызов перегруженной функции pow
Ошибка 1 error C2668: pow: неоднозначный вызов перегруженной функции 2 IntelliSense: существует более одного экземпляра перегруженная...

Неоднозначный вызов перегруженной функции (sqrt)
Вот в программе написано: int n, b; n = sqrt(b); // &lt;-- Неоднозначный вызов перегруженной функции... Может формат записи не тот ?

Ругается на неоднозначный вызов перегруженной функции
Делаю все по примерам не могу понять в чем ошибка. Уверен что ошибка элементарная. Ругается на неоднозначный вызов перегруженной функции....


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
13
Ответ Создать тему
Новые блоги и статьи
PhpStorm 2025.3: WSL Terminal всегда стартует в ~
and_y87 14.12.2025
PhpStorm 2025. 3: WSL Terminal всегда стартует в ~ (home), игнорируя директорию проекта Симптом: После обновления до PhpStorm 2025. 3 встроенный терминал WSL открывается в домашней директории. . .
Access
VikBal 11.12.2025
Помогите пожалуйста !! Как объединить 2 одинаковые БД Access с разными данными.
Новый ноутбук
volvo 07.12.2025
Всем привет. По скидке в "черную пятницу" взял себе новый ноутбук Lenovo ThinkBook 16 G7 на Амазоне: Ryzen 5 7533HS 64 Gb DDR5 1Tb NVMe 16" Full HD Display Win11 Pro
Музыка, написанная Искусственным Интеллектом
volvo 04.12.2025
Всем привет. Некоторое время назад меня заинтересовало, что уже умеет ИИ в плане написания музыки для песен, и, собственно, исполнения этих самых песен. Стихов у нас много, уже вышли 4 книги, еще 3. . .
От async/await к виртуальным потокам в Python
IndentationError 23.11.2025
Армин Ронахер поставил под сомнение async/ await. Создатель Flask заявляет: цветные функции - провал, виртуальные потоки - решение. Не threading-динозавры, а новое поколение лёгких потоков. Откат?. . .
Поиск "дружественных имён" СОМ портов
Argus19 22.11.2025
Поиск "дружественных имён" СОМ портов На странице: https:/ / norseev. ru/ 2018/ 01/ 04/ comportlist_windows/ нашёл схожую тему. Там приведён код на С++, который показывает только имена СОМ портов, типа,. . .
Сколько Государство потратило денег на меня, обеспечивая инсулином.
Programma_Boinc 20.11.2025
Сколько Государство потратило денег на меня, обеспечивая инсулином. Вот решила сделать интересный приблизительный подсчет, сколько государство потратило на меня денег на покупку инсулинов. . . .
Ломающие изменения в C#.NStar Alpha
Etyuhibosecyu 20.11.2025
Уже можно не только тестировать, но и пользоваться C#. NStar - писать оконные приложения, содержащие надписи, кнопки, текстовые поля и даже изображения, например, моя игра "Три в ряд" написана на этом. . .
Мысли в слух
kumehtar 18.11.2025
Кстати, совсем недавно имел разговор на тему медитаций с людьми. И обнаружил, что они вообще не понимают что такое медитация и зачем она нужна. Самые базовые вещи. Для них это - когда просто люди. . .
Создание Single Page Application на фреймах
krapotkin 16.11.2025
Статья исключительно для начинающих. Подходы оригинальностью не блещут. В век Веб все очень привыкли к дизайну Single-Page-Application . Быстренько разберем подход "на фреймах". Мы делаем одну. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2025, CyberForum.ru