c – 提升图书馆格式;得到std :: string
发布时间:2020-12-16 07:49:03 所属栏目:百科 来源:网络整理
导读:我想添加一些我使用boost库格式化的字符串,如下所示 boost::container::vectorstd::string someStringVector;someStringVector.push_back( format("after is x:%f y:%f and before is x:%f y:%frn") % temp.x % temp.y % this-body-GetPosition().x % this
我想添加一些我使用boost库格式化的字符串,如下所示
boost::container::vector<std::string> someStringVector; someStringVector.push_back( format("after is x:%f y:%f and before is x:%f y:%frn") % temp.x % temp.y % this->body->GetPosition().x % this->body->GetPosition().y; 编译器抱怨它不能转换类型,我尝试将.str()附加到格式返回的结尾,但仍然抱怨. 我得到的错误信息是: error C2664: 'void boost::container::vector<T>::push_back( const std::basic_string<_Elem,_Traits,_Ax> &)' : cannot convert parameter 1 from 'boost::basic_format<Ch>' to 'const std::basic_string<_Elem,_Ax> &' 任何人都有一些洞察力 解决方法
您需要在调用boost :: str中包装格式,就像这样:
str( format("after is x:%f y:%f and before is x:%f y:%frn") % temp.x % temp.y % this->body->GetPosition().x % this->body->GetPosition().y) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |