codac 1.5.6
Loading...
Searching...
No Matches
codac2_SepInter.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include <type_traits>
13#include "codac2_Sep.h"
14#include "codac2_Collection.h"
15#include "codac2_SepWrapper.h"
16
17namespace codac2
18{
19 class SepInter : public Sep<SepInter>
20 {
21 public:
22
23 template<typename S>
24 requires (IsSepBaseOrPtr<S> && !std::is_same_v<SepInter,S>)
25 SepInter(const S& s)
26 : Sep<SepInter>(size_of(s)), _seps(s)
27 { }
28
29 template<typename... S>
30 requires (IsSepBaseOrPtr<S> && ...)
31 SepInter(const S&... s)
32 : Sep<SepInter>(size_first_item(s...)), _seps(s...)
33 {
34 assert_release(all_same_size(s...));
35 }
36
37 BoxPair separate(const IntervalVector& x) const;
38
39 template<typename S>
40 requires std::is_base_of_v<SepBase,S>
41 SepInter& operator&=(const S& s)
42 {
43 assert_release(s.size() == this->size());
44 _seps.add_shared_ptr(std::make_shared<S>(s));
45 return *this;
46 }
47
48 SepInter& operator&=(const std::shared_ptr<SepBase>& s)
49 {
50 assert_release(s->size() == this->size());
51 _seps.add_shared_ptr(s);
52 return *this;
53 }
54
55 protected:
56
57 Collection<SepBase> _seps;
58 };
59
60 template<typename S1, typename S2>
61 requires (IsSepBaseOrPtr<S1> && IsSepBaseOrPtr<S2>)
62 inline SepInter operator&(const S1& s1, const S2& s2)
63 {
64 return SepInter(s1,s2);
65 }
66
67 template<typename S2>
68 requires IsSepBaseOrPtr<S2>
69 inline SepInter operator&(const IntervalVector& s1, const S2& s2)
70 {
71 assert_release(s1.size() == s2.size());
72 return SepInter(SepWrapper(s1),s2);
73 }
74
75 template<typename S1>
76 requires IsSepBaseOrPtr<S1>
77 inline SepInter operator&(const S1& s1, const IntervalVector& s2)
78 {
79 assert_release(s1.size() == s2.size());
80 return SepInter(s1,SepWrapper(s2));
81 }
82}