本文整理汇总了C++中std::experimental::string_view::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ string_view::empty方法的具体用法?C++ string_view::empty怎么用?C++ string_view::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::experimental::string_view
的用法示例。
在下文中一共展示了string_view::empty方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: raw_cmd
void client::raw_cmd(const std::experimental::string_view &content)
{
if (content.empty())
throw std::invalid_argument("content is empty.");
con_.write(content.data());
}
示例2: string_contains
bool util::string_contains(const std::experimental::string_view &str, const char c)
{
assert(!str.empty());
assert(c);
return str.find(c) != std::experimental::string_view::npos;
}
示例3: is_integer
bool util::is_integer(const std::experimental::string_view &s)
{
assert(!s.empty());
for (char c: s) {
if (!std::isdigit(c))
return false;
}
return true;
}
示例4: inet_pton
/*
* Validates an ipv4ipv6 address and return the result.
* Thanks, beej!
*/
bool util::valid_ipv46_addr(const std::experimental::string_view &addr)
{
assert(!addr.empty());
/* Unused, but required by inet_pton(). */
unsigned char buf[sizeof(struct in6_addr)];
if (ip_version(addr) == ipv4)
return inet_pton(AF_INET, addr.data(), buf);
else
return inet_pton(AF_INET6, addr.data(), buf);
}
示例5: ip_version
int util::ip_version(const std::experimental::string_view &addr)
{
assert(!addr.empty());
/*
* Feels hackish.
*
* TODO: Look into and confirm/bust above statement.
*/
if (string_contains(addr, period))
return ipv4;
return ipv6;
}
示例6: splitted
static OutputContainer splitted(const std::experimental::string_view &collection, const Element &element) {
OutputContainer output;
if(!collection.empty()) {
unsigned int start = 0, i = 0;
for(; i != collection.size();) {
if(collection[i] == element) {
output.push_back(collection.substr(start, i-start));
++i;
start = i;
} else
++i;
}
output.push_back(collection.substr(start, i));
}
return output;
}
示例7: assert
/*
* Split a string into multiple strings when a character is met.
* Returns all tokens in an array.
*/
std::vector<std::string> util::split_string(const std::experimental::string_view &str, const char c)
{
assert(!str.empty());
assert(c);
using std::experimental::string_view;
std::vector<std::string> result;
for (string_view::const_iterator len = str.begin(); len <= str.end(); len++) {
string_view::const_iterator token_start = len;
while (*len != c && *len)
len++;
result.emplace_back(token_start, len);
}
return result;
}
示例8: isOption
static bool isOption(const std::experimental::string_view& str)
{
assert(!str.empty());
return str.front() == '-';
}