#include <cassert>
#include <cstdint>
#include <initializer_list>
#include <iterator>
#include <tuple>
#include <type_traits>
#include <utility>
#include <folly/Portability.h>
#include <folly/Traits.h>
#include <folly/Utility.h>
#include <folly/container/Access.h>
#include <folly/functional/Invoke.h>
namespace folly {
namespace for_each_detail {
namespace adl {
get;
template <std::size_t Index, typename Type>
auto adl_get(Type&& instance) -> decltype(get<Index>(std::declval<Type>())) { … }
}
EnableIfMemberGetFound;
template <typename, typename T>
struct IsMemberGetFound : std::bool_constant<!require_sizeof<T>> { … };
IsMemberGetFound<EnableIfMemberGetFound<T>, T>;
template <
std::size_t Index,
typename Type,
std::enable_if_t<!IsMemberGetFound<void, Type>::value, int> = 0>
auto get_impl(Type&& instance)
-> decltype(adl::adl_get<Index>(static_cast<Type&&>(instance))) { … }
template <
std::size_t Index,
typename Type,
std::enable_if_t<IsMemberGetFound<void, Type>::value, int> = 0>
auto get_impl(Type&& instance)
-> decltype(static_cast<Type&&>(instance).template get<Index>()) { … }
EnableIfTuple;
template <typename, typename T>
struct IsTuple : std::bool_constant<!require_sizeof<T>> { … };
IsTuple<EnableIfTuple<T>, T>;
EnableIfRange;
template <typename, typename T>
struct IsRange : std::bool_constant<!require_sizeof<T>> { … };
IsRange<EnableIfRange<T>, T>;
struct TupleTag { … };
struct RangeTag { … };
SequenceTag;
struct BeginAddTag { … };
struct IndexingTag { … };
ForEachImplTag;
template <
typename Func,
typename... Args,
std::enable_if_t<is_invocable_r_v<LoopControl, Func, Args...>, int> = 0>
LoopControl invoke_returning_loop_control(Func&& f, Args&&... a) { … }
template <
typename Func,
typename... Args,
std::enable_if_t<!is_invocable_r_v<LoopControl, Func, Args...>, int> = 0>
LoopControl invoke_returning_loop_control(Func&& f, Args&&... a) { … }
template <typename Sequence, typename Func>
void for_each_range_impl(index_constant<3>, Sequence&& range, Func& func) { … }
template <typename Sequence, typename Func>
void for_each_range_impl(index_constant<2>, Sequence&& range, Func& func) { … }
template <typename Sequence, typename Func>
void for_each_range_impl(index_constant<1>, Sequence&& range, Func& func) { … }
template <typename Sequence, typename Func, std::size_t... Indices>
void for_each_tuple_impl(
std::index_sequence<Indices...>, Sequence&& seq, Func& func) { … }
template <typename Sequence, typename Func>
void for_each_tuple_impl(index_constant<2>, Sequence&& seq, Func& func) { … }
template <typename Sequence, typename Func>
void for_each_tuple_impl(index_constant<1>, Sequence&& seq, Func& func) { … }
template <typename Sequence, typename Func>
void for_each_impl(TupleTag, Sequence&& range, Func& func) { … }
template <typename Sequence, typename Func>
void for_each_impl(RangeTag, Sequence&& range, Func& func) { … }
template <typename Sequence, typename Index>
decltype(auto) fetch_impl(IndexingTag, Sequence&& sequence, Index&& index) { … }
template <typename Sequence, typename Index>
decltype(auto) fetch_impl(BeginAddTag, Sequence&& sequence, Index index) { … }
template <typename Sequence, typename Index>
decltype(auto) fetch_impl(TupleTag, Sequence&& sequence, Index index) { … }
template <typename Sequence, typename Index>
decltype(auto) fetch_impl(RangeTag, Sequence&& sequence, Index&& index) { … }
}
template <typename Sequence, typename Func>
constexpr Func for_each(Sequence&& sequence, Func func) { … }
template <typename Sequence, typename Index>
constexpr decltype(auto) fetch(Sequence&& sequence, Index&& index) { … }
}