pine icon indicating copy to clipboard operation
pine copied to clipboard

为什么 Buffer::Size() 返回 ssize_t 而不是 size_t ?

Open loryhndol opened this issue 2 years ago • 0 comments

使用 clang-tidy 后

/home/loryhndol/Public/pine/src/Buffer.cpp:25:33: error: narrowing conversion from 'std::basic_string<char>::size_type' (aka 'unsigned long') to signed type 'ssize_t' (aka 'long') is implementation-defined [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions,-warnings-as-errors]
ssize_t Buffer::Size() { return buf_.size(); }

ssize_t 是有符号整数类型,难道是需要返回错误码?

loryhndol avatar Nov 04 '22 11:11 loryhndol