cMHN 1.1
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
assignable_bool.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_TENSOR_VIEWS_ASSIGNABLE_BOOL_H
4#define pRC_CORE_TENSOR_VIEWS_ASSIGNABLE_BOOL_H
5
12
13namespace pRC::TensorViews
14{
15 template<class N, class F>
16 class Assignable<Bool, N, F> : public View<Bool, N, F>
17 {
18 private:
19 using Base = View<Bool, N, F>;
20
21 public:
22 constexpr auto &operator=(Zero<> const)
23 {
24 return *this = zero<F>();
25 }
26
27 constexpr auto &operator=(Unit<> const)
28 {
29 return *this = unit<F>();
30 }
31
32 constexpr auto &operator=(Identity<> const)
33 {
34 return *this = identity<F>();
35 }
36
37 template<class X, class R = RemoveReference<X>,
38 If<All<IsConvertible<R, Bool>,
39 IsSatisfied<(typename Base::Dimension() == 0)>>> = 0>
40 constexpr auto &operator=(X &&value)
41 {
42 (*this)() = forward<X>(value);
43 return this->self();
44 }
45
46 template<class X, class R = RemoveReference<X>, If<IsTensorish<R>> = 0,
47 If<IsSame<typename Base::Sizes, typename R::Sizes>> = 0,
48 If<IsConvertible<typename R::Type, Bool>> = 0>
49 constexpr auto &operator=(X &&rhs)
50 {
51 if constexpr(IsSubscriptable<Base>() && IsSubscriptable<R>())
52 {
54 [this, &rhs](auto const i)
55 {
56 (*this)[i] = forward<X>(rhs)[i];
57 });
58 }
59 else
60 {
62 [this, &rhs](auto const... indices)
63 {
64 (*this)(indices...) = forward<X>(rhs)(indices...);
65 });
66 }
67 return this->self();
68 }
69
70 protected:
71 ~Assignable() = default;
72 constexpr Assignable(Assignable const &) = default;
73 constexpr Assignable(Assignable &&) = default;
74 constexpr Assignable &operator=(Assignable const &) = delete;
75 constexpr Assignable &operator=(Assignable &&) = delete;
76 constexpr Assignable() = default;
77 };
78}
79#endif // pRC_CORE_TENSOR_VIEWS_ASSIGNABLE_BOOL_H
constexpr Assignable & operator=(Assignable const &)=delete
constexpr auto & operator=(Unit<> const)
Definition assignable_bool.hpp:27
constexpr Assignable(Assignable &&)=default
constexpr Assignable & operator=(Assignable &&)=delete
constexpr auto & operator=(Zero<> const)
Definition assignable_bool.hpp:22
constexpr auto & operator=(X &&rhs)
Definition assignable_bool.hpp:49
constexpr Assignable(Assignable const &)=default
constexpr auto & operator=(X &&value)
Definition assignable_bool.hpp:40
constexpr auto & operator=(Identity<> const)
Definition assignable_bool.hpp:32
Definition assignable.hpp:22
Definition type_traits.hpp:32
Definition diagonal.hpp:11
bool Bool
Definition type_traits.hpp:18
static constexpr auto makeConstantSequence()
Definition sequence.hpp:402
Definition type_traits.hpp:262
Definition type_traits.hpp:265
Definition type_traits.hpp:268