Commit 94dee91f authored by Tom Niget's avatar Tom Niget

Add builtin for lvalue_or_rvalue helper

parent 4d973371
......@@ -237,4 +237,27 @@ typon::Task<PyFile> open(const PyStr &path, std::string_view mode) {
#include "../typon/generator.hpp"
#include <pybind11/embed.h>
#include <pybind11/stl.h>
namespace py = pybind11;
#include <utility>
template <typename Ref>
struct lvalue_or_rvalue {
Ref &&ref;
template <typename Arg>
constexpr lvalue_or_rvalue(Arg &&arg) noexcept
: ref(std::move(arg))
{ }
constexpr operator Ref& () const & noexcept { return ref; }
constexpr operator Ref&& () const && noexcept { return std::move(ref); }
constexpr Ref& operator*() const noexcept { return ref; }
constexpr Ref* operator->() const noexcept { return &ref; }
};
#endif // TYPON_BUILTINS_HPP
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment