SLIDE  3.0.0
A simulator for lithium-ion battery pack degradation
Loading...
Searching...
No Matches
PtrInterval.hpp
Go to the documentation of this file.
1
2/*
3 * PtrInterval.hpp
4 *
5 * Created on: 27 May 2022
6 * Author(s): Jorn Reniers, Volkan Kumtepeli
7 */
8
9#pragma once
10
11#include <vector>
12#include <array>
13#include <span>
14#include <iterator>
15
16//#include <type_traits>
17
18namespace slide {
19template <typename T>
21{
22 T *begin_ptr{ nullptr };
23 T *end_ptr{ nullptr };
24
25public:
26 [[nodiscard]] constexpr T *begin() noexcept { return begin_ptr; }
27 [[nodiscard]] constexpr T *end() noexcept { return end_ptr; }
28
29 size_t size() { return std::distance(begin_ptr, end_ptr); }
30
32 {
33 begin_ptr = &x;
34 end_ptr = begin_ptr + 1;
35 }
36
37 PtrInterval(std::vector<T> &x)
38 {
39 begin_ptr = &x[0];
40 end_ptr = &x.back() + 1;
41 }
42
43 template <size_t N>
44 PtrInterval(std::array<T, N> &x)
45 {
46 begin_ptr = &x[0];
47 end_ptr = &x.back() + 1;
48 }
49
50 PtrInterval(std::span<T> x)
51 {
52 begin_ptr = &x[0];
53 end_ptr = &x.back() + 1;
54 }
55};
56} // namespace slide
< std::span is same size. It is now postponed.
Definition: PtrInterval.hpp:21
PtrInterval(std::array< T, N > &x)
Definition: PtrInterval.hpp:44
PtrInterval(T &x)
Definition: PtrInterval.hpp:31
PtrInterval(std::span< T > x)
Definition: PtrInterval.hpp:50
constexpr T * begin() noexcept
Definition: PtrInterval.hpp:26
size_t size()
Definition: PtrInterval.hpp:29
constexpr T * end() noexcept
Definition: PtrInterval.hpp:27
PtrInterval(std::vector< T > &x)
Definition: PtrInterval.hpp:37
Slide namespace contains all the types, classes, and functions for the simulation framework.
Definition: Cell.hpp:27