Callable.h
1/* Copyright (C) 2026 Marc Boris Duerner
2 SPDX-License-Identifier: LGPL-2.1-or-later WITH mif-exception
3*/
4
5#ifndef Pt_Callable_h
6#define Pt_Callable_h
7
8#include <Pt/Api.h>
9#include <Pt/Invokable.h>
10
11namespace Pt {
12
21template <typename R, typename... As>
22class Callable : public Invokable<As...>
23{
24 public:
30 virtual Callable* clone() const = 0;
31
38 virtual R call(As... args) const = 0;
39
42 R operator()(As... args) const
43 {
44 return this->call(args...);
45 }
46
47 // inherit docs
48 virtual void invoke(As... args) const = 0;
49};
50
51} // namespace Pt
52
53#endif
An interface for all callable entities.
Definition Callable.h:23
virtual Callable * clone() const =0
Returns a copy of this instance.
virtual R call(As... args) const =0
Calls the callable entity and returns its result.
virtual void invoke(As... args) const =0
Invokes the invokable entity with the given arguments.
R operator()(As... args) const
Same as call().
Definition Callable.h:42
Interface for invokable entities.
Definition Invokable.h:57
Core module.
Definition Allocator.h:33