← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2347: add a nullptr impl for GCC < 4.6

 

------------------------------------------------------------
revno: 2347
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sat 2010-12-18 14:38:56 +0100
message:
  add a nullptr impl for GCC < 4.6
added:
  dcpp/nullptr.h
modified:
  dcpp/stdinc.cpp
  dcpp/stdinc.h


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== added file 'dcpp/nullptr.h'
--- dcpp/nullptr.h	1970-01-01 00:00:00 +0000
+++ dcpp/nullptr.h	2010-12-18 13:38:56 +0000
@@ -0,0 +1,20 @@
+// for compilers that don't support nullptr, use the workaround in section 1.1 of the proposal.
+
+#ifdef __GNUC__
+#if __GNUC__ <= 4 && __GNUC_MINOR__ < 6 // GCC 4.6 is the first GCC to implement nullptr.
+
+const // this is a const object...
+class {
+public:
+	template<class T> // convertible to any type
+	operator T*() const // of null non-member
+	{ return 0; } // pointer...
+	template<class C, class T> // or any type of null
+	operator T C::*() const // member pointer...
+	{ return 0; }
+private:
+	void operator&() const; // whose address can't be taken
+} nullptr = {}; // and whose name is nullptr
+
+#endif
+#endif

=== modified file 'dcpp/stdinc.cpp'
--- dcpp/stdinc.cpp	2010-02-11 21:44:13 +0000
+++ dcpp/stdinc.cpp	2010-12-18 13:38:56 +0000
@@ -18,7 +18,17 @@
 
 #include "stdinc.h"
 
-// Hm...version not updated it seems
-#if defined(HAVE_STLPORT) && (_STLPORT_VERSION < 0x513)
-#error "I use STLport 5.1.3. Remove this if you know what you're doing."
+#if defined(__GNUC__)
+#if __GNUC__ <= 4 && __GNUC_MINOR__ <= 5 && __GNUC_PATCHLEVEL__ < 1
+#error GCC 4.5.1 is required
+#endif
+
+#elif defined(_MSC_VER)
+#if _MSC_VER < 1600
+#error MSVC 10 (2010) is required
+#endif
+
+#else
+#error No supported compiler found
+
 #endif

=== modified file 'dcpp/stdinc.h'
--- dcpp/stdinc.h	2010-11-12 17:22:02 +0000
+++ dcpp/stdinc.h	2010-12-18 13:38:56 +0000
@@ -121,6 +121,8 @@
 #include <boost/scoped_array.hpp>
 #include <boost/noncopyable.hpp>
 
+#include "nullptr.h"
+
 namespace dcpp {
 using namespace std;
 }