From 75a0fecf4f4a0615e9a5f7e25194e80693cd51f2 Mon Sep 17 00:00:00 2001
From: Thomas Moulard <thomas.moulard@gmail.com>
Date: Thu, 17 Feb 2011 14:09:08 +0100
Subject: [PATCH] Add nullptr class.

---
 include/CMakeLists.txt            |  1 +
 include/dynamic-graph/null-ptr.hh | 41 +++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)
 create mode 100644 include/dynamic-graph/null-ptr.hh

diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 585472f..7618ba0 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -33,6 +33,7 @@ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/import-default-paths.h
 # Headers list.
 SET(${PROJECT_NAME}_HEADERS
 fwd.hh
+null-ptr.hh
 contiifstream.h
 debug.h
 
diff --git a/include/dynamic-graph/null-ptr.hh b/include/dynamic-graph/null-ptr.hh
new file mode 100644
index 0000000..2842e61
--- /dev/null
+++ b/include/dynamic-graph/null-ptr.hh
@@ -0,0 +1,41 @@
+// Copyright 2010, Thomas Moulard, JRL, CNRS/AIST
+//
+// This file is part of dynamic-graph.
+// dynamic-graph is free software: you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public License
+// as published by the Free Software Foundation, either version 3 of
+// the License, or (at your option) any later version.
+//
+// dynamic-graph is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Lesser Public License for more details.  You should have
+// received a copy of the GNU Lesser General Public License along with
+// dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef DYNAMIC_GRAPH_NULL_PTR_HH
+# define DYNAMIC_GRAPH_NULL_PTR_HH
+
+namespace dynamicgraph
+{
+  const class
+  {
+  public:
+    template<class T>
+    operator T*() const
+    {
+      return 0;
+    }
+    
+    template<class C, class T>
+    operator T C::*() const
+    {
+      return 0;
+    }
+  private:
+    void operator&() const;
+  } nullptr = {};
+
+} // end of namespace dynamicgraph.
+
+#endif //! DYNAMIC_GRAPH_NULL_PTR_HH
-- 
GitLab