common.hpp 858 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #ifndef SIMPLE_MOTION_COMMON_HPP
  2. #define SIMPLE_MOTION_COMMON_HPP
  3. #include "simple/support/range.hpp"
  4. #include "simple/support/type_traits/conversions.hpp" // converts_to
  5. namespace simple::motion
  6. {
  7. template <typename T>
  8. concept basic = requires(T t)
  9. {
  10. {t.advance(typename T::duration{})} -> support::converts_to<bool>;
  11. {t.done()} -> support::converts_to<bool>;
  12. t.reset();
  13. // FIXME: pain points
  14. // t.value();
  15. // t.move(, T::duration{})
  16. };
  17. template <typename Duration>
  18. struct advance_result
  19. {
  20. bool done;
  21. Duration remaining{};
  22. explicit operator bool() { return done; } // negate?
  23. };
  24. template <typename Duration, typename It = size_t>
  25. struct multi_advance_result : public advance_result<Duration>
  26. {
  27. support::range<It> updated {};
  28. using advance_result<Duration>::operator bool;
  29. };
  30. } // namespace simple::motion
  31. #endif /* end of include guard */