Wayverb
named_value.h
1 #pragma once
2 
3 #include <string>
4 
5 namespace util {
6 
7 template <typename T>
8 struct named_value final {
9  named_value(std::string name, T value)
10  : name{std::move(name)}, value{std::move(value)} {}
11 
12  std::string name;
13  T value;
14 };
15 
16 template <typename T>
17 auto make_named_value(std::string name, T value) {
18  return named_value<T>{std::move(name), std::move(value)};
19 }
20 
21 template <typename Callback, typename T>
22 auto map(Callback&& callback, const named_value<T>& t) {
23  return make_named_value(t.name, callback(t.value));
24 }
25 
26 } // namespace util
Definition: allocator.h:6
Definition: named_value.h:8