Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
IDataProvider.h
Go to the documentation of this file.
1#ifndef IPARAMETERPROVIDER_H
2#define IPARAMETERPROVIDER_H
3
4#include <unordered_set>
5#include <string>
6#include <concepts>
7#include <type_traits>
8#include "scalar.h"
9#include <utility>
10
52template <typename, typename... Args>
53struct has_callable_operator : std::false_type {};
54
61template <typename T, typename... Args>
62struct has_callable_operator<T, std::void_t<decltype(std::declval<T>()(std::declval<Args>()...))>, Args...>
63 : std::is_convertible<decltype(std::declval<T>()(std::declval<Args>()...)), scalar_t> {};
64
65template <typename T, typename... Args>
66concept HasCallableOperator = has_callable_operator<T,void, Args...>::value;
67
68template <typename, typename... Args>
69struct has_exists_function : std::false_type {};
70
77template <typename T, typename... Args>
78struct has_exists_function<T, std::void_t<decltype(std::declval<T>().exists(std::declval<Args>()...))>, Args...>
79 : std::is_convertible<decltype(std::declval<T>().exists(std::declval<Args>()...)), bool> {};
80
81template <typename T, typename... Args>
82concept HasExistsFunction = has_exists_function<T, void, Args...>::value;
83
91template<typename T>
93public:
94 virtual ~IDataProvider() = default;
95
96 template<typename... Args>
97 requires HasCallableOperator<T, Args...>
98 double operator()(Args&&... args) {
99 return static_cast<T*>(this)->operator()(std::forward<Args>(args)...);
100 }
101
102 template<typename... Args>
103 requires HasExistsFunction<T, Args...>
104 bool exists(Args&&... args) const {
105 return static_cast<T*>(this)->exists(std::forward<Args>(args)...);
106 }
107};
108
109
110#endif // IPARAMETERPROVIDER_H
Generic interface for providing data through callable and exist methods.
double operator()(Args &&... args)
virtual ~IDataProvider()=default
bool exists(Args &&... args) const
Hash specialization for SymbolId<Tag>.
Definition BlockName.h:353
double T(double x)
Wilson coefficient T(x).