문제

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