19 #include <initializer_list> 22 #include <type_traits> 32 namespace for_each_detail {
49 template <std::
size_t Index,
typename Type>
50 auto adl_get(
Type&& instance) -> decltype(get<Index>(std::declval<Type>())) {
51 return get<Index>(std::forward<Type>(instance));
53 template <
typename Type>
55 return begin(instance);
57 template <
typename Type>
70 template <
typename,
typename T>
85 -> decltype(adl::adl_get<Index>(static_cast<Type&&>(instance))) {
86 return adl::adl_get<Index>(
static_cast<Type&&
>(instance));
93 -> decltype(static_cast<Type&&>(instance).
template get<Index>()) {
94 return static_cast<Type&&
>(instance).
template get<Index>();
102 decltype(get_impl<0>(std::declval<T>())),
104 template <
typename,
typename T>
106 template <
typename T>
116 template <
typename,
typename T>
118 template <
typename T>
127 template <
typename Sequence>
134 template <
typename Func,
typename Item,
typename Iter>
139 is_invocable<Func, Item, index_constant<0>>
::value,
152 return static_cast<Func&&
>(
f)(static_cast<Args&&>(
a)...);
162 "return either LoopControl or void");
163 return static_cast<Func&&
>(
f)(static_cast<Args&&>(
a)...),
loop_continue;
169 template <
typename Sequence,
typename Func>
173 for (
auto index = std::size_t{0};
first != last; ++index) {
182 template <
typename Sequence,
typename Func>
186 auto three_arg_adaptor = [&func](
187 auto&& ele,
auto index,
auto) -> decltype(
auto) {
188 return func(std::forward<decltype(ele)>(ele), index);
191 index_constant<3>{}, std::forward<Sequence>(
range), three_arg_adaptor);
194 template <
typename Sequence,
typename Func>
198 auto three_arg_adaptor = [&func](
auto&& ele,
auto,
auto) -> decltype(
auto) {
199 return func(std::forward<decltype(ele)>(ele));
202 index_constant<3>{}, std::forward<Sequence>(
range), three_arg_adaptor);
208 template <
typename Sequence,
typename Func, std::size_t... Indices>
229 get_impl<Indices>(std::forward<Sequence>(
seq)),
243 template <
typename Sequence,
typename Func>
251 template <
typename Sequence,
typename Func>
255 auto two_arg_adaptor = [&func](
auto&& ele,
auto) -> decltype(
auto) {
256 return func(std::forward<decltype(ele)>(ele));
259 index_constant<2>{}, std::forward<Sequence>(
seq), two_arg_adaptor);
269 template <
typename Sequence,
typename Func>
271 using type = decltype(get_impl<0>(std::declval<Sequence>()));
276 template <
typename Sequence,
typename Func>
279 using type = decltype(*std::declval<iter>());
285 template <
typename Sequence,
typename Index>
287 return std::forward<Sequence>(sequence)[std::forward<Index>(index)];
289 template <
typename Sequence,
typename Index>
291 return *(
adl::adl_begin(std::forward<Sequence>(sequence)) + index);
294 template <
typename Sequence,
typename Index>
295 decltype(
auto)
fetch_impl(TupleTag, Sequence&& sequence, Index index) {
296 return get_impl<index>(std::forward<Sequence>(sequence));
298 template <
typename Sequence,
typename Index>
299 decltype(
auto)
fetch_impl(RangeTag, Sequence&& sequence, Index&& index) {
301 using iter_traits = std::iterator_traits<remove_cvref_t<iter>>;
302 using iter_cat =
typename iter_traits::iterator_category;
303 using tag = std::conditional_t<
308 tag{}, std::forward<Sequence>(sequence), std::forward<Index>(index));
313 template <
typename Sequence,
typename Func>
315 namespace fed = for_each_detail;
316 using tag = fed::SequenceTag<Sequence>;
321 template <
typename Sequence,
typename Index>
323 namespace fed = for_each_detail;
324 using tag = fed::SequenceTag<Sequence>;
326 tag{}, std::forward<Sequence>(sequence), std::forward<Index>(index));
void_t< decltype(get_impl< 0 >(std::declval< T >())), decltype(std::tuple_size< T >::value)> EnableIfTuple
static void for_each_impl(RangeTag, Sequence &&range, Func &func)
static void for_each_impl(TupleTag, Sequence &&range, Func &func)
typename invoke_result< F, Args... >::type invoke_result_t
LoopControl invoke_returning_loop_control(Func &&f, Args &&...a)
auto get_impl(Type &&instance) -> decltype(adl::adl_get< Index >(static_cast< Type && >(instance)))
constexpr auto loop_continue
#define FOLLY_CPP14_CONSTEXPR
std::integral_constant< std::size_t, I > index_constant
void_t< decltype(adl::adl_begin(std::declval< T >())), decltype(adl::adl_end(std::declval< T >()))> EnableIfRange
auto begin(TestAdlIterable &instance)
Gen seq(Value first, Value last)
auto adl_end(Type &&instance) -> decltype(end(instance))
void for_each_range_impl(index_constant< 3 >, Sequence &&range, Func &func)
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
—— Concurrent Priority Queue Implementation ——
bool_constant< true > true_type
void for_each_tuple_impl(index_sequence< Indices... >, Sequence &&seq, Func &func)
constexpr auto size(C const &c) -> decltype(c.size())
decltype(auto) fetch_impl(IndexingTag, Sequence &&sequence, Index &&index)
def Iter(n, format, sep='')
auto end(TestAdlIterable &instance)
make_integer_sequence< std::size_t, Size > make_index_sequence
constexpr Range< Iter > range(Iter first, Iter last)
std::conditional_t< is_invocable< Func, Item, index_constant< 0 >, Iter >::value, index_constant< 3 >, std::conditional_t< is_invocable< Func, Item, index_constant< 0 >>::value, index_constant< 2 >, std::conditional_t< is_invocable< Func, Item >::value, index_constant< 1 >, void >>> ForEachImplTag
type_t< void, Ts... > void_t
static const char *const value
auto adl_get(Type &&instance) -> decltype(get< Index >(std::declval< Type >()))
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
bool_constant< false > false_type
const internal::AnythingMatcher _
auto adl_begin(Type &&instance) -> decltype(begin(instance))
decltype(auto) FOLLY_CPP14_CONSTEXPR fetch(Sequence &&sequence, Index &&index)
std::conditional_t< IsRange< void, Sequence >::value, RangeTag, TupleTag > SequenceTag
PUSHMI_INLINE_VAR constexpr detail::get_fn< T > get
void_t< decltype(std::declval< T >().template get< 0 >())> EnableIfMemberGetFound
constexpr auto loop_break
FOLLY_CPP14_CONSTEXPR Func for_each(Sequence &&sequence, Func func)
constexpr detail::First first