Reactions  0.0.0
Handling reaction trees and decays
element_traits.hpp
Go to the documentation of this file.
1 
4 #pragma once
5 
6 #include "reactions/pdg.hpp"
7 #include "reactions/pow_enum.hpp"
8 
9 #include <functional>
10 #include <string>
11 
12 namespace reactions {
15 } // namespace reactions
16 
20 
22  template <class T> struct properties;
23 
25  template <> struct properties<reactions::pdg_element> {
26  using type = reactions::pdg_element;
27  static constexpr auto builder = [](std::string const &s) {
28  return reactions::pdg_database::instance()(s);
29  };
30  };
31 
33  template <> struct properties<reactions::string_element> {
35  static constexpr auto builder = [](std::string const &s) { return s; };
36  };
37 
39  template <class T> using element_t = typename properties<T>::type;
40 
42  template <class T> static constexpr auto builder = properties<T>::builder;
43 
45  template <class T> using builder_t = decltype(builder<T>);
46 
48  template <class T>
50 } // namespace reactions::element_traits
Define properties for a given element kind.
Definition: element_traits.hpp:22
std::string string_element
Alias for an element based on a simple string.
Definition: element_traits.hpp:14
STL class.
static constexpr auto builder
Default builder for a given kind of element.
Definition: element_traits.hpp:42
Contains macros to define smart enumeration types.
std::function< T(std::string const &)> const & builder_tpl_t
General builder type for a given kind of element.
Definition: element_traits.hpp:49
Main namespace of the Reactions package.
Definition: all.hpp:21
typename properties< T >::type element_t
Actual C++ type for the given kind of element.
Definition: element_traits.hpp:39
Handle the properties of elements.
Definition: element_traits.hpp:19
decltype(builder< T >) builder_t
Default builder type for a given kind of element.
Definition: element_traits.hpp:45
reactions::pdg_element type
Definition: element_traits.hpp:26