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
6
namespace
impl
7
{
8
template
<ModelType T>
9
requires
(!
has_species_name<T>
)
10
auto
11
get_species_names_impl
()
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
24
get_species_names_impl
()
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
has_species_name
Definition
traits.hpp:56
impl
Definition
species_name_extractor.hpp:7
impl::get_species_names_impl
auto get_species_names_impl()
Definition
species_name_extractor.hpp:11
apps
libs
mc
includes
species_name_extractor.hpp
Generated by
1.14.0