codac 2.0.5
Loading...
Searching...
No Matches
codac2_Collection.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include <type_traits>
13#include <cassert>
14#include <list>
15#include <memory>
16
17namespace codac2
18{
19 template<typename T>
20 class Collection : public std::list<std::shared_ptr<T>>
21 {
22 public:
23
24 Collection()
25 { }
26
27 template<typename... T_>
28 requires ((!std::is_same_v<Collection<T>,T_>) && ...)
29 Collection(const T_&... x)
30 {
31 (this->push_back(x), ...);
32 }
33
34 Collection(std::initializer_list<std::shared_ptr<T>> init)
35 : std::list<std::shared_ptr<T>>(init)
36 { }
37
38 template<typename T_>
39 requires std::is_base_of_v<T,T_>
40 Collection(std::initializer_list<T_> x)
41 {
42 for(const auto& xi : x)
43 this->push_back(xi);
44 }
45
46 Collection(const Collection<T>& c)
47 : std::list<std::shared_ptr<T>>()
48 {
49 for(const auto& ci : c)
50 {
51 assert(ci);
52 this->push_back(std::dynamic_pointer_cast<T>(ci->copy()));
53 }
54 }
55
56 template<typename T_>
57 requires std::is_base_of_v<T,T_>
58 void push_back(const T_& x)
59 {
60 this->push_back(std::make_shared<T_>(x));
61 }
62
63 template<typename T_>
64 requires std::is_base_of_v<T,T_>
65 void push_back(const std::shared_ptr<T_>& x)
66 {
67 this->std::list<std::shared_ptr<T>>::push_back(x);
68 }
69 };
70}
auto & init()
Initializes all elements of the matrix with default intervals.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:113
Definition codac2_OctaSym.h:21