本文整理汇总了C++中string_view::to_string方法的典型用法代码示例。如果您正苦于以下问题:C++ string_view::to_string方法的具体用法?C++ string_view::to_string怎么用?C++ string_view::to_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类string_view
的用法示例。
在下文中一共展示了string_view::to_string方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_strview_compare
void test_strview_compare(const string_view& a, const string_view& b) {
std::string as = a.to_string();
std::string bs = b.to_string();
auto sg = [](int x) { return x == 0 ? 0 : (x < 0 ? -1 : 1); };
int c = as.compare(bs);
ASSERT_EQ(sg(c), sg(a.compare(b)));
ASSERT_EQ(sg(c), sg(a.compare(bs.c_str())));
ASSERT_EQ(c == 0, a == b);
ASSERT_EQ(c != 0, a != b);
ASSERT_EQ(c < 0, a < b);
ASSERT_EQ(c <= 0, a <= b);
ASSERT_EQ(c > 0, a > b);
ASSERT_EQ(c >= 0, a >= b);
ASSERT_EQ((-c) == 0, b == a);
ASSERT_EQ((-c) != 0, b != a);
ASSERT_EQ((-c) < 0, b < a);
ASSERT_EQ((-c) <= 0, b <= a);
ASSERT_EQ((-c) > 0, b > a);
ASSERT_EQ((-c) >= 0, b >= a);
}
示例2: checkout_tree
static void checkout_tree(gitdb & db, string_view dir, gitdb::tree_t const & t)
{
for (auto && te: t)
{
std::string name = dir.to_string() + "/" + te.name;
if ((te.mode & 0xe000) == 0xe000)
{
// XXX gitlink
}
else if (te.mode & 0x4000)
{
make_directory(name);
checkout_tree(db, name, db.get_tree(te.oid));
}
else
{
file ff(name, /*readonly=*/false);
std::vector<uint8_t> v = db.get_blob(te.oid);
file::ofile fo = ff.seekp(0);
write_all(fo, v.data(), v.size());
}
}
}
示例3: normalize_path
std::string normalize_path(string_view path, uri_comparison_level level) {
auto result = path.to_string();
if (uri_comparison_level::syntax_based == level) {
// case normalization
detail::for_each(result, percent_encoded_to_upper<std::string>());
// % encoding normalization
result.erase(
detail::decode_encoded_unreserved_chars(std::begin(result),
std::end(result)),
std::end(result));
// % path segment normalization
result = normalize_path_segments(result);
}
return result;
}
示例4: Nonnull
Win32Exception::Win32Exception(ErrorCode ec, string_view msg, const char* fn,
RecordLevel lv)
: Win32Exception(ec, msg.to_string() + " @ " + Nonnull(fn), lv)
{}
示例5: find
typename base::const_iterator find(const string_view& key) const
{
return this->base::find(key.to_string());
}