aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/atom.h14
-rw-r--r--src/tests/atom.cpp8
2 files changed, 22 insertions, 0 deletions
diff --git a/src/atom.h b/src/atom.h
index f876274..a0469b6 100644
--- a/src/atom.h
+++ b/src/atom.h
@@ -84,6 +84,20 @@ namespace Bu
84 return *this; 84 return *this;
85 } 85 }
86 86
87 t *operator ->()
88 {
89 if( !pData )
90 throw Bu::ExceptionBase("Not set");
91 return pData;
92 }
93
94 t &operator *()
95 {
96 if( !pData )
97 throw Bu::ExceptionBase("Not set");
98 return *pData;
99 }
100
87 private: 101 private:
88 t *pData; 102 t *pData;
89 talloc ta; 103 talloc ta;
diff --git a/src/tests/atom.cpp b/src/tests/atom.cpp
index cf076b1..2077bfd 100644
--- a/src/tests/atom.cpp
+++ b/src/tests/atom.cpp
@@ -2,10 +2,18 @@
2#include <stdio.h> 2#include <stdio.h>
3#include <stdlib.h> 3#include <stdlib.h>
4 4
5typedef struct bob
6{
7 int a, b;
8} bob;
5int main() 9int main()
6{ 10{
7 Bu::Atom<int> aInt; 11 Bu::Atom<int> aInt;
8 Bu::Atom<char *> aStr; 12 Bu::Atom<char *> aStr;
13 Bu::Atom<bob> aBob;
14
15 aBob = bob();
16 aBob->a = 5;
9 17
10 aStr.set("Hey there, dude"); 18 aStr.set("Hey there, dude");
11 aInt.set( 55 ); 19 aInt.set( 55 );