cMHN 1.1
C++ library for learning MHNs with pRC
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_TENSOR_VIEWS_ENUMERATE_H
4#define pRC_TENSOR_TRAIN_TENSOR_VIEWS_ENUMERATE_H
5
9
11{
12 template<class T, 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, N, Ranks, Enumerate<T, N, Ranks, F, Vs...>>,
18 View<T, N, Ranks, Enumerate<T, 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>()...))>,
27
28 public:
29 template<class... Xs, If<All<IsSame<Vs, RemoveReference<Xs>>...>> = 0>
30 Enumerate(F f, Xs &&...args)
31 : mF(forward<F>(f))
32 , mArgs(forward<Xs>(args)...)
33 {
34 }
35
36 using Base::operator=;
37
38 template<Index C>
39 constexpr decltype(auto) core()
40 {
42 [this](auto const... ops) -> decltype(auto)
43 {
44 return mF.template operator()<C>(
45 get<ops>(mArgs).template core<C>()...);
46 });
47 }
48
49 template<Index C>
50 constexpr decltype(auto) core() const
51 {
53 [this](auto const... ops) -> decltype(auto)
54 {
55 return mF.template operator()<C>(
56 get<ops>(mArgs).template core<C>()...);
57 });
58 }
59
60 private:
61 F mF;
62 tuple<Vs...> mArgs;
63 };
64}
65#endif // pRC_TENSOR_TRAIN_TENSOR_VIEWS_ENUMERATE_H
Definition type_traits.hpp:40
Definition enumerate.hpp:19
constexpr decltype(auto) core()
Definition enumerate.hpp:39
Enumerate(F f, Xs &&...args)
Definition enumerate.hpp:30
constexpr decltype(auto) core() const
Definition enumerate.hpp:50
Definition type_traits.hpp:37
pRC::Float<> T
Definition externs_nonTT.hpp:1
Definition type_traits.hpp:35
static constexpr auto makeConstantSequence()
Definition sequence.hpp:402
std::enable_if_t< B{}, int > If
Definition type_traits.hpp:68
std::conditional_t< B{}, T, F > Conditional
Definition type_traits.hpp:131
std::conjunction< Bs... > All
Definition type_traits.hpp:77
static constexpr decltype(auto) expand(Sequence< T, Seq... > const, F &&f, Xs &&...args)
Definition sequence.hpp:344
Definition type_traits.hpp:66