File: SettingsHelper.h

package info (click to toggle)
ausaxs 1.1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 72,592 kB
  • sloc: cpp: 49,853; ansic: 6,901; python: 730; makefile: 18
file content (20 lines) | stat: -rw-r--r-- 457 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// SPDX-License-Identifier: LGPL-3.0-or-later
// Author: Kristian Lytje

#pragma once

#include <functional>

namespace ausaxs::settings::detail {
    template<typename T>
    struct Setting {
        T value;
        std::function<void(T&)> on_change;
        T& operator=(T other) {
            if (on_change) {on_change(other);}
            value = std::move(other);
            return value;
        }
        operator T() const {return value;}
    };
}