summaryrefslogtreecommitdiff
path: root/tiger-compiler/lib/misc/deref.hh
diff options
context:
space:
mode:
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>