Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
Ref.h
1 /*
2  * $Id$
3  * Copyright (c) 2006 - IRIT-UPS <casse@irit.fr>
4  *
5  * Ref class interface.
6  */
7 #ifndef ELM_UTIL_REF_H
8 #define ELM_UTIL_REF_H
9 
10 #include <elm/io.h>
11 
12 namespace elm {
13 
14 using namespace io;
15 
16 // Ref class
17 template <class T>
18 class Ref {
19  T *ptr;
20 public:
21  inline Ref(T *_ptr): ptr(_ptr) { }
22  inline Ref(const Ref<T>& ref): ptr(ref.ptr) { }
23  inline operator T& (void) const { return *ptr; }
24  inline T *operator&(void) const { return ptr; }
25  inline T& operator*(void) const { return *ptr; }
26  inline T *operator->(void) const { return ptr; }
27  inline Ref<T>& operator=(T *_ptr)
28  { ptr = _ptr; return *this; }
29  inline Ref<T>& operator=(const Ref<T>& ref)
30  { ptr = ref.ptr; return *this; }
31  inline Ref<T>& operator=(const T& val)
32  { *ptr = val; return *this; }
33 };
34 
35 // Display
36 template <class T>
37 inline Output& operator<<(Output& out, const Ref<T>& ref) {
38  out << *ref;
39  return out;
40 }
41 
42 } // elm
43 
44 #endif // ELM_UTIL_REF_H
elm::io::out
sys::SystemOutStream & out
Definition: system_SystemIO.cpp:122
elm::t::ref
mut< T > ref(var< T > &x)
Definition: type_info.h:289
elm::Ref::Ref
Ref(T *_ptr)
Definition: Ref.h:21
elm::Ref::operator->
T * operator->(void) const
Definition: Ref.h:26
elm::Ref
Definition: Ref.h:18
void
elm::io::operator<<
Output & operator<<(Output &out, const T &v)
Definition: Output.h:216
elm::Ref::operator&
T * operator&(void) const
Definition: Ref.h:24
elm::Ref::operator=
Ref< T > & operator=(const T &val)
Definition: Ref.h:31
elm
Definition: adapter.h:26
elm::Ref::operator=
Ref< T > & operator=(const Ref< T > &ref)
Definition: Ref.h:29
elm::Ref::Ref
Ref(const Ref< T > &ref)
Definition: Ref.h:22
elm::Ref::operator=
Ref< T > & operator=(T *_ptr)
Definition: Ref.h:27
elm::io::Output
Definition: Output.h:179
elm::Ref::operator*
T & operator*(void) const
Definition: Ref.h:25