Reaktoro  v2.11.0
A unified framework for modeling chemically reactive systems
Types.hpp
1 // Reaktoro is a unified framework for modeling chemically reactive systems.
2 //
3 // Copyright © 2014-2024 Allan Leal
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library. If not, see <http://www.gnu.org/licenses/>.
17 
18 #pragma once
19 
20 // C++ includes
21 #include <any>
22 #include <array>
23 #include <cstddef>
24 #include <deque>
25 #include <functional>
26 #include <memory>
27 #include <optional>
28 #include <string>
29 #include <unordered_map>
30 #include <unordered_set>
31 #include <variant>
32 #include <vector>
33 
34 // Third-party includes
35 #include <tsl/ordered_map.h>
36 
37 // Reaktoro includes
38 #include <Reaktoro/Common/Real.hpp>
39 
40 namespace Reaktoro {
41 
43 using Index = std::size_t;
44 
46 using Indices = std::vector<Index>;
47 
49 using Chars = const char*;
50 
52 using String = std::string;
53 
55 using Strings = std::vector<std::string>;
56 
58 using StringOrIndex = std::variant<Index, int, std::string>;
59 
61 template<typename T, std::size_t N>
62 using Array = std::array<T, N>;
63 
65 template<typename T>
66 using Vec = std::vector<T>;
67 
69 template<typename T>
70 using Deque = std::deque<T>;
71 
73 template<typename Key, typename T>
74 using Map = std::unordered_map<Key, T>;
75 
76 // Conveniet alias to `std::unordered_set<T>`
77 template<typename T>
78 using Set = std::unordered_set<T>;
79 
80 // Conveniet alias to `tsl::ordered_map<Key, T>`
81 template<class Key, class T>
82 using Dict = tsl::ordered_map<Key, T>;
83 
85 template<typename T, typename U>
86 using Pair = std::pair<T, U>;
87 
89 template<typename T, typename U>
91 
93 template<typename... Args>
94 using Tuple = std::tuple<Args...>;
95 
97 template<typename... Args>
98 using Tuples = Vec<Tuple<Args...>>;
99 
101 template<typename T>
102 using Ptr = std::unique_ptr<T>;
103 
105 template<typename T>
106 using SharedPtr = std::shared_ptr<T>;
107 
109 template<typename F>
110 using Fn = std::function<F>;
111 
113 template<typename T>
114 using Optional = std::optional<T>;
115 
117 template<typename T>
118 using OptionalRef = std::optional<std::reference_wrapper<T>>;
119 
121 template<typename T>
122 using OptionalConstRef = std::optional<std::reference_wrapper<const T>>;
123 
125 using Any = std::any;
126 
128 using Nullptr = std::nullptr_t;
129 
130 } // namespace Reaktoro
The namespace containing all components of the Reaktoro library.
Definition: Algorithms.hpp:29
std::array< T, N > Array
Convenient alias for std::array<T, N>.
Definition: Types.hpp:62
std::optional< std::reference_wrapper< T > > OptionalRef
Convenient alias for std::optional<std::reference_wrapper<T>>.
Definition: Types.hpp:118
Vec< Pair< T, U > > Pairs
Convenient alias for std::vector<std::pair<T, U>>.
Definition: Types.hpp:90
std::nullptr_t Nullptr
Convenient alias for std::nullptr_t.
Definition: Types.hpp:128
std::vector< T > Vec
Convenient alias for std::vector<T>.
Definition: Types.hpp:66
std::pair< T, U > Pair
Convenient alias for std::pair<T, U>.
Definition: Types.hpp:86
std::string String
Convenient alias for std::string.
Definition: Types.hpp:52
std::size_t Index
Define a type that represents an index.
Definition: Index.hpp:26
std::vector< std::string > Strings
Convenient alias for std::vector<String>.
Definition: Types.hpp:55
std::unique_ptr< T > Ptr
Convenient alias for std::unique_ptr<T>.
Definition: Types.hpp:102
std::deque< T > Deque
Convenient alias for std::deque<T>.
Definition: Types.hpp:70
std::variant< Index, int, std::string > StringOrIndex
The type used to accept either a name or an index.
Definition: Types.hpp:58
std::tuple< Args... > Tuple
Convenient alias for std::tuple<Args...>.
Definition: Types.hpp:94
const char * Chars
Convenient alias for const char*.
Definition: Types.hpp:49
std::optional< std::reference_wrapper< const T > > OptionalConstRef
Convenient alias for std::optional<std::reference_wrapper<const T>>.
Definition: Types.hpp:122
std::any Any
Convenient alias for std::any.
Definition: Types.hpp:125
std::optional< T > Optional
Convenient alias for std::optional<T>.
Definition: Types.hpp:114
std::function< F > Fn
Convenient alias for std::function<R(Args...)>.
Definition: Types.hpp:110
std::vector< Index > Indices
Define a type that represents a collection of indices.
Definition: Index.hpp:29
std::shared_ptr< T > SharedPtr
Convenient alias for std::shared_ptr<T>.
Definition: Types.hpp:106
Vec< Tuple< Args... > > Tuples
Convenient alias for std::vector<std::tuple<Args...>>.
Definition: Types.hpp:98
std::unordered_map< Key, T > Map
Convenient alias for std::unordered_map<Key, T>.
Definition: Types.hpp:74