#include <alpaqa/util/type-erasure.hpp>
#include <functional>
Go to the source code of this file.
◆ ALPAQA_TE_REQUIRED_METHOD
#define ALPAQA_TE_REQUIRED_METHOD |
( |
|
vtable, |
|
|
|
type, |
|
|
|
member |
|
) |
| |
Value: do { \
static_assert( \
requires { &type::member; }, \
"Missing required method '" #type "::" #member "'"); \
(vtable).member = util::type_erased_wrapped<&type::member>(); \
} while (0)
Definition at line 6 of file required-method.hpp.
◆ ALPAQA_TE_OPTIONAL_METHOD
#define ALPAQA_TE_OPTIONAL_METHOD |
( |
|
vtable, |
|
|
|
type, |
|
|
|
member, |
|
|
|
instance_p |
|
) |
| |
Value: do { \
if constexpr (requires { &type::member; }) { \
using vtable_t = std::remove_cvref_t<decltype(vtable)>; \
auto assign_vtable = [&] { \
(vtable).member = \
util::type_erased_wrapped<&type::member, \
const vtable_t &>(); \
}; \
if constexpr (requires { &type::provides_##member; }) { \
if (std::invoke(&type::provides_##member, instance_p)) \
assign_vtable(); \
} else { \
assign_vtable(); \
} \
} \
} while (0)
Definition at line 13 of file required-method.hpp.