Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
set/map equal_range bug in libc++
#include <set> #include <iostream> #include <iterator> struct comparator { using range_t = std::pair<int, int>; using is_transparent = std::true_type; bool operator()(int lhs, int rhs) const { return lhs < rhs; } bool operator()(int lhs, range_t rhs) const { return lhs < rhs.first; } bool operator()(range_t lhs, int rhs) const { return lhs.second < rhs; } }; using range_set = std::set<int, comparator>; int main() { range_set set = { 1, 3, 6, 10 }; auto range = comparator::range_t{2, 7}; auto eq = set.equal_range(range); auto low = set.lower_bound(range); auto high = set.upper_bound(range); std::cout << "equal_range returned " << std::distance(eq.first, eq.second) << " elem(s): "; std::copy(eq.first, eq.second, std::ostream_iterator<int>(std::cout, " ")); std::cout << "\nlower/upper returned " << std::distance(low, high) << " elem(s): "; std::copy(low, high, std::ostream_iterator<int>(std::cout, " ")); std::cout << '\n'; return 0; }
run
|
edit
|
history
|
help
0
std::function copies
Crow unordered_map Quiz
11/18
Tree Traversal and Node
ECE2574_Function_Calling_Example
New wall
using directives: qualified lookup rules are different from unqualified lookup rules
Segment Tree Impl
problem_name_1
Template arguments may contain calls to constexpr functions.