pRC
multi-purpose Tensor Train library for C++
Loading...
Searching...
No Matches
enumerate.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_TENSOR_TRAIN_OPERATOR_VIEWS_ENUMERATE_H
4#define pRC_TENSOR_TRAIN_OPERATOR_VIEWS_ENUMERATE_H
5
9
11{
12 template<class T, class M, class N, class Ranks, class F, class... Vs>
14 : public Conditional<
15 IsAssignable<decltype(declval<F>().template operator()<0>(
16 declval<Vs>().template core<0>()...))>,
17 Assignable<T, M, N, Ranks, Enumerate<T, M, N, Ranks, F, Vs...>>,
18 View<T, M, N, Ranks, Enumerate<T, M, N, Ranks, F, Vs...>>>
19 {
20 static_assert(All<Any<IsTensorView<Vs>, IsOperatorView<Vs>>...>());
21
22 private:
23 using Base = Conditional<
25 declval<Vs>().template core<0>()...))>,
28
29 public:
30 template<class... Xs, If<All<IsSame<Vs, RemoveReference<Xs>>...>> = 0>
31 Enumerate(F f, Xs &&...args)
32 : mF(forward<F>(f))
33 , mArgs(forward<Xs>(args)...)
34 {
35 }
36
37 using Base::operator=;
38
39 template<Index C>
40 constexpr decltype(auto) core()
41 {
43 [this](auto const... ops) -> decltype(auto)
44 {
45 return mF.template operator()<C>(
46 get<ops>(mArgs).template core<C>()...);
47 });
48 }
49
50 template<Index C>
51 constexpr decltype(auto) core() const
52 {
54 [this](auto const... ops) -> decltype(auto)
55 {
56 return mF.template operator()<C>(
57 get<ops>(mArgs).template core<C>()...);
58 });
59 }
60
61 private:
62 F mF;
63 tuple<Vs...> mArgs;
64 };
65}
66#endif // pRC_TENSOR_TRAIN_OPERATOR_VIEWS_ENUMERATE_H
Definition type_traits.hpp:40
constexpr decltype(auto) core()
Definition enumerate.hpp:40
constexpr decltype(auto) core() const
Definition enumerate.hpp:51
Enumerate(F f, Xs &&...args)
Definition enumerate.hpp:31
Definition type_traits.hpp:37
Definition type_traits.hpp:35
std::conjunction< Bs... > All
Definition type_traits.hpp:77
std::enable_if_t< B{}, int > If
Definition type_traits.hpp:68
static constexpr Conditional< IsSatisfied< C >, RemoveConstReference< X >, X > copy(X &&a)
Definition copy.hpp:13
std::conditional_t< B{}, T, F > Conditional
Definition type_traits.hpp:131
static constexpr decltype(auto) expand(Sequence< T, Seq... > const, F &&f, Xs &&...args)
forwards the values in a pRC::Sequence to a function as parameters
Definition sequence.hpp:354
Definition type_traits.hpp:66