LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
supplier.hpp
Go to the documentation of this file.
1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 */
6#pragma once
7
8#include <functional>
9
10namespace okapi {
16template <typename T> class Supplier {
17 public:
18 explicit Supplier(std::function<T(void)> ifunc) : func(ifunc) {
19 }
20
21 virtual ~Supplier() = default;
22
27 T get() const {
28 return func();
29 }
30
31 protected:
32 std::function<T(void)> func;
33};
34} // namespace okapi
A supplier of instances of T.
Definition supplier.hpp:16
T get() const
Get an instance of type T.
Definition supplier.hpp:27
Supplier(std::function< T(void)> ifunc)
Definition supplier.hpp:18
virtual ~Supplier()=default
std::function< T(void)> func
Definition supplier.hpp:32