diff options
author | crupest <crupest@outlook.com> | 2019-04-02 21:01:16 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-04-02 21:01:16 +0800 |
commit | 4ea8be24492f58564ff1b1efe9f7c4673078bcbc (patch) | |
tree | 7494d20ed04763936555547a6a10caa870567353 /include/cru/platform/painter_util.hpp | |
parent | 1091b720bab98908dc89931b3d54c37729d33df2 (diff) | |
download | cru-4ea8be24492f58564ff1b1efe9f7c4673078bcbc.tar.gz cru-4ea8be24492f58564ff1b1efe9f7c4673078bcbc.tar.bz2 cru-4ea8be24492f58564ff1b1efe9f7c4673078bcbc.zip |
...
Diffstat (limited to 'include/cru/platform/painter_util.hpp')
-rw-r--r-- | include/cru/platform/painter_util.hpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/include/cru/platform/painter_util.hpp b/include/cru/platform/painter_util.hpp index fed0c487..5711d099 100644 --- a/include/cru/platform/painter_util.hpp +++ b/include/cru/platform/painter_util.hpp @@ -2,13 +2,17 @@ #include "painter.hpp" #include <functional> +#include <type_traits> namespace cru::platform::util { +template <typename Fn> inline void WithTransform(Painter* painter, const Matrix& matrix, - const std::function<void(Painter*)>& action) { + const Fn& action) { + static_assert(std::is_invocable_v<decltype(action), Painter*>, + "Action must can be be invoked with painter."); const auto old = painter->GetTransform(); painter->SetTransform(old * matrix); action(painter); painter->SetTransform(old); } -} +} // namespace cru::platform::util |