summaryrefslogtreecommitdiff
path: root/tiger-compiler/lib/misc/deref.hh
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
commit967be9e750221ab2ab783f95df79bb26d290a45e (patch)
tree6802900a5e975f9f68b169f0f503f040056d6952 /tiger-compiler/lib/misc/deref.hh
add: added projectsHEADmain
Diffstat (limited to 'tiger-compiler/lib/misc/deref.hh')
-rw-r--r--tiger-compiler/lib/misc/deref.hh41
1 files changed, 41 insertions, 0 deletions
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 <iosfwd>
+
+#include <misc/ref.hh>
+
+namespace misc
+{
+ enum deref_e
+ {
+ deref
+ };
+
+ class Deref
+ {
+ protected:
+ Deref(std::ostream&);
+
+ public:
+ template <typename T> std::ostream& operator<<(const T* t) const;
+ template <typename T> std::ostream& operator<<(T* t) const;
+ template <typename T> std::ostream& operator<<(const ref<T>& t) const;
+ template <typename T> std::ostream& operator<<(const T& t) const;
+ template <typename T> 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 <misc/deref.hxx>