Example #1
0
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);
		}
	}
}
Example #2
0
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");
   }
}
	T front() const {
		return elements.front().lb;
	}