cpp-stat-bench 0.24.0
Benchmark library with statistics for C++.
Loading...
Searching...
No Matches
parameter_value_vector.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 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 <cstddef>
23#include <utility> // IWYU pragma: keep
24#include <vector>
25
27
28namespace stat_bench {
29namespace param {
30
34class IParameterValueVector {
35public:
37 using ConstIterator = std::vector<ParameterValue>::const_iterator;
38
44 [[nodiscard]] virtual auto begin() const -> ConstIterator = 0;
45
51 [[nodiscard]] virtual auto end() const -> ConstIterator = 0;
52
58 [[nodiscard]] virtual auto size() const -> std::size_t = 0;
59
60 IParameterValueVector(const IParameterValueVector&) = delete;
61 IParameterValueVector(IParameterValueVector&&) = delete;
62 auto operator=(const IParameterValueVector&)
63 -> IParameterValueVector& = delete;
64 auto operator=(IParameterValueVector&&) -> IParameterValueVector& = delete;
65
69 virtual ~IParameterValueVector() = default;
70
71protected:
75 IParameterValueVector() = default;
76};
77
83template <typename T>
84class ParameterValueVector final : public IParameterValueVector {
85public:
90
97 auto add(const T& value) -> ParameterValueVector* {
98 values_.push_back(std::move(ParameterValue().emplace<T>(value)));
99 return this;
100 }
101
103 [[nodiscard]] auto begin() const -> ConstIterator override {
104 return values_.begin();
105 }
106
108 [[nodiscard]] auto end() const -> ConstIterator override {
109 return values_.end();
110 }
111
113 [[nodiscard]] auto size() const -> std::size_t override {
114 return values_.size();
115 }
116
119 auto operator=(const ParameterValueVector&)
120 -> ParameterValueVector& = delete;
121 auto operator=(ParameterValueVector&&) -> ParameterValueVector& = delete;
122
126 ~ParameterValueVector() override = default;
127
128private:
130 std::vector<ParameterValue> values_{};
131};
132
133} // namespace param
134} // namespace stat_bench
std::vector< ParameterValue >::const_iterator ConstIterator
Type of iterators.
virtual auto end() const -> ConstIterator=0
Get the iterator of the past-the-end element.
virtual auto begin() const -> ConstIterator=0
Get the iterator of the first element.
virtual auto size() const -> std::size_t=0
Get the number of values.
Class of vectors of parameter values.
auto size() const -> std::size_t override
Get the number of values.
auto end() const -> ConstIterator override
Get the iterator of the past-the-end element.
ParameterValueVector()=default
Constructor.
auto add(const T &value) -> ParameterValueVector *
Add a value.
auto begin() const -> ConstIterator override
Get the iterator of the first element.
~ParameterValueVector() override=default
Destructor.
Class of values of parameters.
Namespace of parameters of benchmarks.
Namespace of stat_bench source codes.
STL namespace.
Definition of ParameterValue class.