Вопрос

In mdart/mdart_function.h, function hash is defined.

inline nsaddr_t hash(nsaddr_t id) {
    bitset<ADDR_SIZE> tempAddress_ (id);
    bitset<ADDR_SIZE> address_;
    for(unsigned int i=0; i<ADDR_SIZE; i++) {
        if (tempAddress_.test(i)) {
            address_.set(ADDR_SIZE - 1 - i);
        }
    }
    address_.flip(ADDR_SIZE - 1);
    nsaddr_t temp = (nsaddr_t) address_.to_ulong();
#ifdef DEBUG
    fprintf(stdout, "\thash = %s\n", bitString(temp));
#endif
    return temp;
}

In another source file, the hash function is referenced with correct header include:

nsaddr_t dstAdd_ = hash(reqId);

However, there is another hash, std::hash and it throws error: reference to 'hash' is ambiguous when I build it.

Is there any way to specify which hash the source code tries to use? I know std::hash, but how about hash in the header file?

Это было полезно?

Решение

You can use the namespace that the custom hash function is in to disambiguate it. If it's not in an explicit namespace, then just ::hash() will find it in the global namespace.

Другие советы

If your own hash implementation is in no particular namespace, you can use ::hash to refer to it.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top