20 #include <initializer_list> 30 using namespace folly;
40 this->constructed_from_rvalue =
true;
43 this->constructed_from_rvalue =
false;
48 bool constructed_from_rvalue{
false};
53 std::vector<int>
vec{0, 1, 2, 3};
57 return instance.
vec.begin();
60 return instance.
vec.begin();
63 return instance.
vec.end();
66 return instance.
vec.end();
88 this->called_begin =
true;
99 bool called_begin =
false;
104 TEST(Foreach, ForEachFunctionBasic) {
106 auto result_range = std::vector<int>{};
107 auto correct_result_range = std::vector<int>{1, 2, 3};
112 result_range.begin(), result_range.end(), correct_result_range.begin()));
115 TEST(Foreach, ForEachFunctionBasicRuntimeOneArg) {
116 auto range = std::vector<int>{1, 2, 3};
130 TEST(Foreach, ForEachFunctionBasicRuntimeTwoArg) {
131 auto range = std::vector<int>{1, 2, 3};
136 }
else if (index == 1) {
138 }
else if (index == 2) {
144 TEST(Foreach, ForEachFunctionBasicRuntimeThreeArg) {
145 auto range = std::list<int>{1, 2, 3};
146 auto result_range = std::list<int>{1, 3};
155 TEST(Foreach, ForEachFunctionBasicTupleOneArg) {
170 TEST(Foreach, ForEachFunctionBasicTupleTwoArg) {
176 }
else if (index == 1) {
178 }
else if (index == 2) {
184 TEST(Foreach, ForEachFunctionBreakRuntimeOneArg) {
185 auto range = std::vector<int>{1, 2, 3};
189 if (iterations == 1) {
197 TEST(Foreach, ForEachFunctionBreakRuntimeTwoArg) {
198 auto range = std::vector<int>{1, 2, 3};
210 TEST(Foreach, ForEachFunctionBreakRuntimeThreeArg) {
211 auto range = std::vector<int>{1, 2, 3};
223 TEST(Foreach, ForEachFunctionBreakTupleOneArg) {
224 auto range = std::vector<int>{1, 2, 3};
228 if (iterations == 1) {
236 TEST(Foreach, ForEachFunctionBreakTupleTwoArg) {
237 auto range = std::vector<int>{1, 2, 3};
249 TEST(Foreach, ForEachFunctionArray) {
250 auto range = std::array<int, 3>{{1, 2, 3}};
262 TEST(Foreach, ForEachFunctionInitializerListBasic) {
263 folly::for_each(std::initializer_list<int>{1, 2, 3}, [](
auto ele) { ++ele; });
266 TEST(Foreach, ForEachFunctionTestForward) {
268 auto range_one = std::vector<TestRValueConstruct>{};
277 [](
auto ele) {
EXPECT_TRUE(ele.constructed_from_rvalue); });
280 TEST(Foreach, ForEachFunctionAdlIterable) {
291 auto vec = std::vector<int>{1, 2, 3};
299 auto mp = std::map<int, int>{{1, 2}};
308 auto& ele =
folly::fetch(mp, std::integral_constant<int, 1>{});
324 const char*
const hello =
"hello";
341 auto len = hello.size();
346 std::map<std::string, int>
testMap;
362 TEST(Foreach, ForEachKVBreak) {
363 std::map<std::string, int>
testMap;
380 TEST(Foreach, ForEachKvWithMultiMap) {
381 std::multimap<std::string, int>
testMap;
382 testMap.insert(std::make_pair(
"abc", 1));
383 testMap.insert(std::make_pair(
"abc", 2));
384 testMap.insert(std::make_pair(
"def", 3));
398 TEST(Foreach, ForEachEnumerate) {
402 int numIterations = 0;
425 TEST(Foreach, ForEachEnumerateBreak) {
429 int numIterations = 0;
459 std::list<int> lst = {0, 1, 2, 3, 4};
std::atomic< int64_t > sum(0)
#define FOR_EACH_KV(k, v, c)
auto begin(const TestAdlIterable &instance)
constexpr auto loop_continue
#define EXPECT_EQ(val1, val2)
constexpr detail::Map< Move > move
TestRValueConstruct(const TestRValueConstruct &)
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
constexpr Range< Iter > range(Iter first, Iter last)
std::random_access_iterator_tag iterator_category
#define FOR_EACH_ENUMERATE(count, i, c)
#define EXPECT_TRUE(condition)
TestRValueConstruct(TestRValueConstruct &&) noexcept
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
#define EXPECT_FALSE(condition)
decltype(auto) FOLLY_CPP14_CONSTEXPR fetch(Sequence &&sequence, Index &&index)
void ForEach(const Container &c, Functor functor)
#define FOR_EACH_RANGE_R(i, begin, end)
TEST(SequencedExecutor, CPUThreadPoolExecutor)
std::size_t difference_type
constexpr auto loop_break
FOLLY_CPP14_CONSTEXPR Func for_each(Sequence &&sequence, Func func)
auto end(const TestAdlIterable &instance)
std::vector< int > values(1'000)