libhv icon indicating copy to clipboard operation
libhv copied to clipboard

Add const qualifier for `TcpClient::isReconnect()` method.

Open Guo-Shiyu opened this issue 2 years ago • 2 comments

Guo-Shiyu avatar Nov 11 '23 10:11 Guo-Shiyu

这个不加const会有什么影响吗?

ithewei avatar Nov 13 '23 03:11 ithewei

In my use case, the following code will cause a compile error without compile flag -fpermissive .

void f(const hv::TcpClient* raw) { // or `const hv::TcpClient&`
    if (raw->isReconnet()) {
        ... 
    } 
    // compile error: `raw` has type `const hv::TcpClient*` but member function
    // `TcpCLient::isReconnect()` not marked as const.

}

Add const qualifier for this method will not intruduce any incompatibility to existed code. So it would be a good fix?

Guo-Shiyu avatar Nov 15 '23 03:11 Guo-Shiyu