numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
member_function_iteration_parameter_value.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 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// IWYU pragma: no_include <functional>
23// IWYU pragma: no_include <string_view>
24
25#include <type_traits> // IWYU pragma: keep
26
30
32
46template <typename Algorithm,
47 concepts::formattable_iteration_parameter_value Value,
48 concepts::member_getter_of<Value, Algorithm> Function>
50public:
52 using return_type = std::invoke_result_t<Function, Algorithm*>;
53
60 : function_(function) {}
61
69 [[nodiscard]] auto get() const -> return_type {
70 throw invalid_argument(
71 "Evaluation of this parameter value requires the pointer to the "
72 "algorithm.");
73 }
74
81 [[nodiscard]] auto get(const Algorithm* algorithm) const noexcept
82 -> return_type {
83 return (algorithm->*function_)();
84 }
85
86private:
88 Function function_;
89};
90
91} // namespace num_collect::logging::iterations
Class of exception on invalid arguments.
Definition exception.h:85
Class of parameters values in iterations specified by member functions.
auto get(const Algorithm *algorithm) const noexcept -> return_type
Get the current value.
std::invoke_result_t< Function, Algorithm * > return_type
Type returned by the function.
Definition of exceptions.
Definition of formattable_iteration_parameter_value concept.
Definition of member_getter_of class.