deref_proxy.h 438 B

1234567891011121314151617
  1. #pragma once
  2. namespace jvalidate::detail {
  3. /**
  4. * @brief An object that acts like a pointer to an rvalue - without requiring us
  5. * to heap allocate a unique_ptr.
  6. * @tparam T the type being pointer to.
  7. */
  8. template <typename T> struct DerefProxy {
  9. T & operator*() { return value; }
  10. T const & operator*() const { return value; }
  11. T * operator->() { return &value; }
  12. T const * operator->() const { return &value; }
  13. T value;
  14. };
  15. }