FuncSketch
Loading...
Searching...
No Matches
math_function_list.h
Go to the documentation of this file.
1/*
2 * Copyright 2026 MusicScience37 (Kenta Kabashima)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
20#pragma once
21
22#include <optional>
23#include <string>
24#include <unordered_map>
25#include <utility>
26
29
30namespace func_sketch::math {
31
36public:
40 MathFunctionList() = default;
41
47 template <MathFunctionType T>
48 void emplace(T&& function) {
49 functions_.emplace(function.name(), std::forward<T>(function));
50 }
51
58 [[nodiscard]] std::optional<MathFunction> get(
59 const std::string& name) const {
60 const auto iter = functions_.find(name);
61 if (iter != functions_.end()) {
62 return iter->second;
63 }
64 return std::nullopt;
65 }
66
67private:
69 std::unordered_map<std::string, MathFunction> functions_;
70};
71
72} // namespace func_sketch::math
std::unordered_map< std::string, MathFunction > functions_
List of mathematical functions.
MathFunctionList()=default
Constructor.
void emplace(T &&function)
Append a mathematical function to the list.
std::optional< MathFunction > get(const std::string &name) const
Get a mathematical function from the list.
Definition of MathFunction class.
Definition of MathFunctionType concept.