aboutsummaryrefslogtreecommitdiff
path: root/src/utils.hpp
blob: 2a49bd390059ce64b012f15241c348fef48c2f8a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#pragma once

#include <memory>

#define DELEGATE(OBJ, METHOD, METHOD_AS)                                                           \
  template <typename... Args> inline decltype(auto) METHOD_AS(Args &&...args) {                    \
    return (OBJ)->METHOD(std::forward<Args>(args)...);                                             \
  }

#define DEFINE_SETTER(METHOD, PROPERTY)                                                            \
  template <typename Arg> inline void METHOD(Arg val) { PROPERTY = val; }

#define DEFINE_GETTER(METHOD, EXPR)                                                                \
  decltype(auto) inline METHOD() const { return EXPR; }

#define DEFER(DEFERRED_BLOCK) std::shared_ptr<void> __deferred(nullptr, [](...) DEFERRED_BLOCK);