From 967be9e750221ab2ab783f95df79bb26d290a45e Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:07:58 +0200 Subject: add: added projects --- tiger-compiler/lib/misc/deref.hh | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tiger-compiler/lib/misc/deref.hh (limited to 'tiger-compiler/lib/misc/deref.hh') diff --git a/tiger-compiler/lib/misc/deref.hh b/tiger-compiler/lib/misc/deref.hh new file mode 100644 index 0000000..3d4598c --- /dev/null +++ b/tiger-compiler/lib/misc/deref.hh @@ -0,0 +1,41 @@ +/** + ** \file misc/deref.hh + ** \brief Automatically derefencing pointers on ostreams. + **/ + +#pragma once + +#include + +#include + +namespace misc +{ + enum deref_e + { + deref + }; + + class Deref + { + protected: + Deref(std::ostream&); + + public: + template std::ostream& operator<<(const T* t) const; + template std::ostream& operator<<(T* t) const; + template std::ostream& operator<<(const ref& t) const; + template std::ostream& operator<<(const T& t) const; + template std::ostream& operator<<(T& t) const; + + protected: + friend Deref operator<<(std::ostream&, deref_e); + + std::ostream& ostr_; + }; + + Deref operator<<(std::ostream& ostr, deref_e); + +} // namespace misc + +#include -- cgit v1.2.3