BioCMAMC-ST
species_name_extractor.hpp
1#ifndef __SPECIES_NAME_EXTRACTOR_HPP__
2#define __SPECIES_NAME_EXTRACTOR_HPP__
3
4#include <mc/traits.hpp>
5
6namespace impl
7{
8 template <ModelType T>
9 requires(!has_species_name<T>)
10 auto
12 {
13 std::vector<std::string> v(T::n_c);
14
15 std::generate(
16 v.begin(), v.end(), [n = 0]() mutable { return std::to_string(n++); });
17
18 return v;
19 }
20
21 template <ModelType T>
22 requires has_species_name<T>
23 auto
25 {
26 auto rd = T::species();
27
28 if (rd.size() != T::n_c)
29 {
30 throw std::invalid_argument("Missing species names");
31 }
32
33 return std::vector<std::string>(rd.begin(), rd.end());
34 }
35} // namespace impl
36
37#endif
Definition traits.hpp:56
Definition species_name_extractor.hpp:7
auto get_species_names_impl()
Definition species_name_extractor.hpp:11