summaryrefslogtreecommitdiff
path: root/tiger-compiler/lib/misc/deref.hh
blob: 3d4598ca01721df6fce737d235539c59636c3026 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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>