本文整理汇总了C++中Cont::front方法的典型用法代码示例。如果您正苦于以下问题:C++ Cont::front方法的具体用法?C++ Cont::front怎么用?C++ Cont::front使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cont
的用法示例。
在下文中一共展示了Cont::front方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GAppSetOpts_ranged
inline void GAppSetOpts_ranged(const char *value, Cont& cont) {
cont.clear();
bool had_range = false;
const char *comma = value;
do {
uint32_t low = abs(atoi(comma)), high = low;
const char *delim = strchr(comma, '-');
const char *nextc = strchr(comma, ',');
if (delim && (nextc == 0 || nextc > delim)) {
had_range = true;
high = abs(atoi(delim + 1));
}
for (; low <= high; ++low) {
cont.push_back(low);
}
} while ((comma = strchr(comma, ',')) != 0 && ++comma && *comma != 0);
if (cont.size() == 1 && !had_range) {
uint32_t val = cont.front();
cont.clear();
for (uint32_t i = 1; i <= val; ++i) {
cont.push_back(i);
}
}
}
示例2: updateContainer
void updateContainer(Cont<T, Alloc>& cont) {
// flip a coin to determine using emplace_back() with 80% of likelihood, or pop_back() with 20% of likelihood.
static std::bernoulli_distribution dist(.8);
if (cont.empty() || dist(S1::s_gen)) {
cont.emplace_back();
} else {
cont.pop_back();
}
// and with 20% likelihood mutating 1st and last elem's std::string field
if (!cont.empty() && !dist(S1::s_gen)) {
cont.front().m_str.append("- foo");
cont.back().m_str.append("- bar");
}
}
示例3: front
T front() const {
return elements.front().lb;
}