• [^] # Re: nom de variable C/C++

    Posté par (site web personnel) . En réponse au journal nom de variable C/C++. Évalué à 0.

    Tu veut dire ca: ?

    Rq: Il a ete fait pour gcc 3.1 je ne sais pas s'il est tjrs valable.

    #ifndef _HASH_FUN_EXT_HH
    #define _HASH_FUN_EXT_HH

    #include <ext/hash_map>

    namespace __gnu_cxx {
    inline size_t __stl_hash_std_string(std::string __s)
    {
    std::string::iterator i;
    unsigned long __h = 0;
    for (i=__s.begin() ; i != __s.end(); ++i)
    __h = 5*__h + *i;

    return size_t(__h);
    }
    template<> struct hash<std::string>
    {
    size_t operator()(const std::string __s) const
    { return __stl_hash_std_string(__s); }
    };

    template<> struct hash<const std::string>
    {
    size_t operator()(const std::string __s) const
    { return __stl_hash_std_string(__s); }
    };
    }

    #endif