Skip to content

Use std::function instead of C-style Callback/UserPtr mechanism #33

Description

@marti4d

I believe there are a few places this is done in Anvil (Keypress callbacks, validation callbacks, window drawFrame callbacks), but C++11 introduced std::function to STL, which creates a typesafe alternative to the old, type-unsafe, memory-leaky, C-style callback mechanism of passing a "Function Pointer + (void* userArgs)" pair and holding your nose while you use reinterpret_cast<>. It also accepts Functors, Lambda Expressions, Pointer-to-member-functions, etc, which are starting to become much more prominent in modern C++ code.

It would be nice down-the-road to see all instances of callbacks used in Anvil to adopt this newer mechanism.

Metadata

Metadata

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions