uint16_t cluster_pool::slot_from_key(const std::string &key)
{
    static const std::regex slot_regex("[^{]*\\{([^}]+)\\}.*");
    std::smatch results;
    uint16_t slot = 0;
    if ( std::regex_match(key, results, slot_regex))
    {
        slot = utils::crc16(results[1]);
    }
    else
    {
        slot = utils::crc16(key);
    }
    return slot & 0x3FFF;
}

https://github.com/luca3m/redis3m/blob/master/src/cluster_pool.cpp

 

GitHub - luca3m/redis3m: A C++ Redis client

A C++ Redis client. Contribute to luca3m/redis3m development by creating an account on GitHub.

github.com

 

redis3m 사용중인데 lib 를 새로 빌드했더니 regex 에서 exception 이 발생했다.

https://stackoverflow.com/questions/12530406/is-gcc-4-8-or-earlier-buggy-about-regular-expressions

 

Is gcc 4.8 or earlier buggy about regular expressions?

I am trying to use std::regex in a C++11 piece of code, but it appears that the support is a bit buggy. An example: #include <regex> #include <iostream> int main (int argc, const char *

stackoverflow.com

확인해보니 regex 는 GCC 4.9.0 에 구현되어 릴리즈 되었다고 한다. 미구현인데 컴파일은 가능해서 런타임에 오류가 발생하는 상황이었다. :(

728x90

+ Recent posts