Frage

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?

War es hilfreich?

Lösung

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.

Andere Tipps

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top