C++ Visual Studio中的警告C4267:&x27;参数';:从';尺寸';至';常数';,数据可能丢失

C++ Visual Studio中的警告C4267:&x27;参数';:从';尺寸';至';常数';,数据可能丢失,c++,C++,我从这个函数中得到警告: std::pair<size_t, size_t> GetSection(const string& s1, const string& s2) { size_t top_section = s1.find(s2 + ":"); size_t bottom_section = s1.find(s1.length() - top_section); return std::m

我从这个函数中得到警告:

std::pair<size_t, size_t> GetSection(const string& s1, const string& s2) {
        size_t top_section = s1.find(s2 + ":");
        size_t bottom_section = s1.find(s1.length() - top_section);

        return std::make_pair(top_section, bottom_section);
}
std::pair GetSection(常量字符串&s1,常量字符串&s2){
大小\u t顶部\u部分=s1。查找(s2+“:”);
size\u t bottom\u section=s1.find(s1.length()-top\u section);
返回std::生成_对(顶部_段、底部_段);
}
我不明白是什么转换导致了问题。 我也知道这个函数可以这样写:

    std::pair<size_t, size_t> GetSection(const string& s1, const string& s2) {
        size_t top_section = s1.find(s2 + ":");
        size_t bottom_section = top_section + s2.length() + 1;

        return std::make_pair(top_section, bottom_section);
}
std::pair GetSection(常量字符串&s1,常量字符串&s2){
大小\u t顶部\u部分=s1。查找(s2+“:”);
底部截面尺寸=顶部截面+s2.长度()+1;
返回std::生成_对(顶部_段、底部_段);
}

我只想知道为什么会收到此警告。

此函数调用中存在问题:

s1.find(s1.length() - top_section);
参数
s1.length()-top\u section
是一个类型数
size\u t
,但是
find
方法应该包含要搜索的字符串或字符

(具体来说,因为C++总是假定您所说的是什么意思,它试图将<代码> SiZeStt <代码>转换成<代码> char < /C> >,但这会导致精度的损失,因为 char 类型只有8位宽。)< /P> <代码> S1.查找(S1. LothTh()-Topx节);<代码>这应该是什么

查找