[Rcpp-commits] r4068 - in pkg/Rcpp: . inst/include inst/include/Rcpp/internal inst/include/Rcpp/sugar inst/include/Rcpp/traits inst/include/Rcpp/vector inst/unitTests src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Dec 4 04:14:48 CET 2012


Author: edd
Date: 2012-12-04 04:14:47 +0100 (Tue, 04 Dec 2012)
New Revision: 4068

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/DESCRIPTION
   pkg/Rcpp/inst/include/Rcpp/internal/wrap.h
   pkg/Rcpp/inst/include/Rcpp/sugar/sugar.h
   pkg/Rcpp/inst/include/Rcpp/traits/comparator_type.h
   pkg/Rcpp/inst/include/Rcpp/vector/Vector.h
   pkg/Rcpp/inst/include/RcppCommon.h
   pkg/Rcpp/inst/unitTests/runit.wrap.R
   pkg/Rcpp/src/RcppCommon.cpp
Log:
Applying patch Yan Zhou for better C++11 support


Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2012-12-04 02:55:08 UTC (rev 4067)
+++ pkg/Rcpp/ChangeLog	2012-12-04 03:14:47 UTC (rev 4068)
@@ -1,11 +1,25 @@
 2012-12-04 Romain Francois <romain at r-enthusiasts.com>
 
-        * include/Rcpp/hash/hash.h: new implementation of IndexHash, based on 
-        Simon's fastmatch package
+        * include/Rcpp/hash/hash.h: new implementation of IndexHash, based on
+	Simon's fastmatch package
         * include/Rcpp/hash/hash_impl.h: low level implementation details
         * include/Rcpp/sugar/functions/match.h: using new IndexHash
         * src/fastmatch.c : largely inspired from Simon's fastmatch
 
+2012-12-03  Dirk Eddelbuettel  <edd at debian.org>
+
+	* inst/include/RcppCommon.h: Applied patch kindly contributed by Yan
+	Zhou which provides a number of more refined definition for support
+	of both the C++11 standard and different compilers
+	* inst/include/Rcpp/internal/wrap.h: Idem
+	* inst/include/Rcpp/sugar/sugar.h: Idem
+	* inst/include/Rcpp/traits/comparator_type.h: Idem
+	* inst/include/Rcpp/vector/Vector.h: Idem
+	* inst/unitTests/runit.wrap.R: Idem
+	* src/RcppCommon.cpp: Idem
+
+	* DESCRIPTION: Increase minor dev. version once more
+
 2012-12-03  JJ Allaire <jj at rstudio.org>
 
         * R/Attributes.R: added function to check whether R development
@@ -15,8 +29,8 @@
 
         * src/Module.cpp: move BEGIN_RCPP/END_RCPP to Module__invoke
         * src/coerce.cpp: added coerce_to_string implementations
-        * include/RcppCommon.h : nicer formatting for RCPP_DEBUG_*, now up to 
-        RCPP_DEBUG_5
+        * include/RcppCommon.h : nicer formatting for RCPP_DEBUG_*, now up to
+	RCPP_DEBUG_5
         * include/Rcpp/vector/Vector.h: debugging
         * include/Rcpp/String.h: The String class
         * include/Rcpp/as.h: support for String
@@ -30,7 +44,7 @@
         * unitTests/cpp/String.cpp : unit tests for String
         * unitTests/runit.String.R: unit test for String
         * include/Rcpp/sugar/sets.h: support for String
-        
+
 2012-12-01  Dirk Eddelbuettel  <edd at debian.org>
 
 	* inst/include/RcppCommon.h: Applied patch by Yan Zhou to add support

Modified: pkg/Rcpp/DESCRIPTION
===================================================================
--- pkg/Rcpp/DESCRIPTION	2012-12-04 02:55:08 UTC (rev 4067)
+++ pkg/Rcpp/DESCRIPTION	2012-12-04 03:14:47 UTC (rev 4068)
@@ -1,6 +1,6 @@
 Package: Rcpp
 Title: Seamless R and C++ Integration
-Version: 0.10.1.2
+Version: 0.10.1.3
 Date: $Date$
 Author: Dirk Eddelbuettel and Romain Francois, with contributions 
  by Douglas Bates, John Chambers and JJ Allaire

Modified: pkg/Rcpp/inst/include/Rcpp/internal/wrap.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/internal/wrap.h	2012-12-04 02:55:08 UTC (rev 4067)
+++ pkg/Rcpp/inst/include/Rcpp/internal/wrap.h	2012-12-04 03:14:47 UTC (rev 4068)
@@ -427,7 +427,7 @@
 template <typename T>
 inline SEXP wrap_dispatch_unknown_iterable(const T& object, ::Rcpp::traits::false_type){
 	// here we know that T is not convertible to SEXP
-#ifdef HAS_CXX0X
+#ifdef HAS_STATIC_ASSERT
 	static_assert( !sizeof(T), "cannot convert type to SEXP" ) ;
 #else
 	// leave the cryptic message

Modified: pkg/Rcpp/inst/include/Rcpp/sugar/sugar.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/sugar.h	2012-12-04 02:55:08 UTC (rev 4067)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/sugar.h	2012-12-04 03:14:47 UTC (rev 4068)
@@ -22,7 +22,6 @@
 #ifndef RCPP_SUGAR_H
 #define RCPP_SUGAR_H
 
-#include <Rcpp/sugar/sets.h>
 #include <Rcpp/sugar/tools/iterator.h>
 #include <Rcpp/sugar/block/block.h>
 

Modified: pkg/Rcpp/inst/include/Rcpp/traits/comparator_type.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/traits/comparator_type.h	2012-12-04 02:55:08 UTC (rev 4067)
+++ pkg/Rcpp/inst/include/Rcpp/traits/comparator_type.h	2012-12-04 03:14:47 UTC (rev 4068)
@@ -28,7 +28,7 @@
    
 class StringCompare {
 public:
-    inline bool operator()( SEXP x, SEXP y){
+    inline bool operator()( SEXP x, SEXP y) const {
         return strcmp( char_nocheck(x), char_nocheck(y) ) < 0 ; 
     }
 } ;

Modified: pkg/Rcpp/inst/include/Rcpp/vector/Vector.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/vector/Vector.h	2012-12-04 02:55:08 UTC (rev 4067)
+++ pkg/Rcpp/inst/include/Rcpp/vector/Vector.h	2012-12-04 03:14:47 UTC (rev 4068)
@@ -264,7 +264,7 @@
         RObject::setSEXP( internal::vector_from_string<RTYPE>(st) );
     }
 	
-#ifdef HAS_INIT_LISTS
+#ifdef HAS_CXX0X_INITIALIZER_LIST
     Vector( std::initializer_list<init_type> list ) : RObject(){
         assign( list.begin() , list.end() ) ;
     }

Modified: pkg/Rcpp/inst/include/RcppCommon.h
===================================================================
--- pkg/Rcpp/inst/include/RcppCommon.h	2012-12-04 02:55:08 UTC (rev 4067)
+++ pkg/Rcpp/inst/include/RcppCommon.h	2012-12-04 03:14:47 UTC (rev 4068)
@@ -68,22 +68,6 @@
 
 #ifdef __GNUC__
     #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
-    #ifdef __GXX_EXPERIMENTAL_CXX0X__
-        #define HAS_CXX0X
-        #if GCC_VERSION >= 40300
-            #define HAS_VARIADIC_TEMPLATES
-        #endif
-        #if GCC_VERSION >= 40400
-            #define HAS_INIT_LISTS
-        #endif
-    #endif
-    // FIXME: [romain] I did not actually check, tr1::unordered_map was 
-    // probably introduced before GCC 4.2.1
-    #if GCC_VERSION >= 40201
-        #define HAS_TR1
-        #define HAS_TR1_UNORDERED_MAP
-        #define HAS_TR1_UNORDERED_SET
-    #endif
     // g++ 4.5 does not seem to like some of the fast indexing
     #if GCC_VERSION >= 40500
         #define IS_GCC_450_OR_LATER
@@ -97,46 +81,84 @@
     #endif
 #endif
 
-// #ifdef __clang__
-//     #define CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
-//     #if CLANG_VERSION < 30000
-//         #define IS_EARLIER_THAN_CLANG_300
-//     #endif
-//     #if CLANG_VERSION >= 30000
-//         #define IS_CLANG_300_OR_LATER
-//     #endif
-// #endif
-
-// This definition was contributed by Yan Zhou
-#ifdef __clang__
-    #if !__has_include(<tr1/unordered_map>)
-        #undef HAS_TR1
-        #undef HAS_TR1_UNORDERED_MAP
+// Check C++0x features
+#if defined(__INTEL_COMPILER)
+    #if __cplusplus >= 201103L
+        #define HAS_CXX0X_FLAG
+        #if __INTEL_COMPILER >= 1210
+            // #define HAS_VARIADIC_TEMPLATES
+        #endif
+        #if __INTEL_COMPILER >= 1100
+            #define HAS_STATIC_ASSERT
+        #endif
     #endif
-    #if !__has_include(<tr1/unordered_set>)
-        #undef HAS_TR1
-        #undef HAS_TR1_UNORDERED_SET
+#elif defined(__clang__)
+    #if __cplusplus >= 201103L
+        #define HAS_CXX0X_FLAG
+        #if __has_feature(cxx_variadic_templates)
+            // #define HAS_VARIADIC_TEMPLATES
+        #endif
+        #if __has_feature(cxx_static_assert)
+            #define HAS_STATIC_ASSERT
+        #endif
     #endif
-    #if __has_feature(cxx_variadic_templates)
-        #define HAS_VARIADIC_TEMPLATES
+#elif defined(__GNUC__)
+    #ifdef __GXX_EXPERIMENTAL_CXX0X__
+        // #define HAS_CXX0X_FLAG
+        #if GCC_VERSION >= 40300
+            // #define HAS_VARIADIC_TEMPLATES
+            #define HAS_STATIC_ASSERT
+        #endif
     #endif
 #endif
 
-#ifdef __INTEL_COMPILER
-    // This is based on an email by Alexey Stukalov who tested 
-    // Intel Compiler 12.0 and states that is does support Cxx0x 
-    // or even TR1 (by default; maybe there are options?)
-    // Extended further via patch in email by Yan Zhou
-    #undef HAS_VARIADIC_TEMPLATES
-    #include <cmath>
-    #ifndef __GLIBCXX__
-    #undef HAS_TR1
-    #undef HAS_TR1_UNORDERED_MAP
-    #undef HAS_TR1_UNORDERED_SET
+// Check C++0x headers
+#include <cmath>
+#if defined(__INTEL_COMPILER) || (defined(__GNUC__) && !defined(__clang__))
+    #if defined(__GLIBCXX__) && defined(__GXX_EXPERIMENTAL_CXX0X__)
+        #if __GLIBCXX__ >= 20090421 // GCC 4.4.0
+            #define HAS_CXX0X_UNORDERED_MAP
+            #define HAS_CXX0X_UNORDERED_SET
+            #define HAS_CXX0X_INITIALIZER_LIST
+        #endif
     #endif
+#elif defined(__clang__)
+    #if __cplusplus >= 201103L
+        #if __has_include(<unordered_map>)
+            #define HAS_CXX0X_UNORDERED_MAP
+        #endif
+        #if __has_include(<unordered_set>)
+            #define HAS_CXX0X_UNORDERED_SET
+        #endif
+        #if __has_include(<initializer_list>)
+            #define HAS_CXX0X_INITIALIZER_LIST
+        #endif
+    #endif
 #endif
 
+// Check TR1 Headers
+#if defined(__INTEL_COMPILER) || (defined(__GNUC__) && !defined(__clang__))
+    #if defined(__GLIBCXX__)
+        #if __GLIBCXX__ >= 20070719 // GCC 4.2.1
+            #define HAS_TR1_UNORDERED_MAP
+            #define HAS_TR1_UNORDERED_SET
+        #endif
+    #endif
+#elif defined(__clang__)
+    #if __cplusplus >= 201103L
+        #if __has_include(<tr1/unordered_map>)
+            #define HAS_TR1_UNORDERED_MAP
+        #endif
+        #if __has_include(<tr1/unordered_set>)
+            #define HAS_TR1_UNORDERED_SET
+        #endif
+    #endif
+#endif
 
+#if defined(HAS_TR1_UNORDERED_MAP) && defined(HAS_TR1_UNORDERED_SET)
+#define HAS_TR1
+#endif
+
 #include <iterator>
 #include <exception>
 #include <iostream>
@@ -156,31 +178,41 @@
 #include <typeinfo>
 #include <Rcpp/sprintf.h>
 
-#ifdef HAS_INIT_LISTS
+// Conditionally include headers
+#ifdef HAS_CXX0X_INITIALIZER_LIST
 #include <initializer_list>
 #endif
 
-#ifdef HAS_TR1_UNORDERED_MAP
-#include <tr1/unordered_map>
-#endif
-
-#ifdef HAS_TR1_UNORDERED_SET
-#include <tr1/unordered_set>
-#endif
-
-
-#if __cplusplus >= 201103L
-    #if defined(__GLIBCXX__) && __GLIBCXX__ > 20090421
-    #include <unordered_map>
-    #include <unordered_set>
-    #elif defined(__clang__)
-        #if __has_include(<unordered_map>)
+#ifdef HAS_CXX0X_FLAG
+    #if defined(HAS_CXX0X_UNORDERED_MAP)
         #include <unordered_map>
-        #endif
-        #if __has_include(<unordered_set>)
+        #define RCPP_UNORDERED_MAP std::unordered_map
+    #else
+        #include <map>
+        #define RCPP_UNORDERED_MAP std::map
+    #endif
+    #if defined(HAS_CXX0X_UNORDERED_SET)
         #include <unordered_set>
-        #endif
+        #define RCPP_UNORDERED_SET std::unordered_set
+    #else
+        #include <set>
+        #define RCPP_UNORDERED_SET std::set
     #endif
+#else
+    #if defined(HAS_TR1_UNORDERED_MAP)
+        #include <tr1/unordered_map>
+        #define RCPP_UNORDERED_MAP std::tr1::unordered_map
+    #else
+        #include <map>
+        #define RCPP_UNORDERED_MAP std::map
+    #endif
+    #if defined(HAS_TR1_UNORDERED_SET)
+        #include <tr1/unordered_set>
+        #define RCPP_UNORDERED_SET std::tr1::unordered_set
+    #else
+        #include <set>
+        #define RCPP_UNORDERED_SET std::set
+    #endif
 #endif
 
 std::string demangle( const std::string& name) ;

Modified: pkg/Rcpp/inst/unitTests/runit.wrap.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.wrap.R	2012-12-04 02:55:08 UTC (rev 4067)
+++ pkg/Rcpp/inst/unitTests/runit.wrap.R	2012-12-04 03:14:47 UTC (rev 4068)
@@ -142,7 +142,7 @@
         ## definition of all the tr1 functions at once, appended to existing list
         g <- list("unordered_map_string_int"=list(
                   signature(),
-                  'std::tr1::unordered_map< std::string, int > m ;
+                  'RCPP_UNORDERED_MAP< std::string, int > m ;
 	           m["b"] = 100;
   	           m["a"] = 200;
   	           m["c"] = 300;
@@ -150,7 +150,7 @@
 
                   ,"unordered_map_string_double"=list(
                    signature(),
-                   'std::tr1::unordered_map<std::string,double> m ;
+                   'RCPP_UNORDERED_MAP<std::string,double> m ;
 	            m["b"] = 100;
   	            m["a"] = 200;
   	            m["c"] = 300;
@@ -158,7 +158,7 @@
 
                   ,"unordered_map_string_bool"=list(
                    signature(),
-                   'std::tr1::unordered_map<std::string,bool> m ;
+                   'RCPP_UNORDERED_MAP<std::string,bool> m ;
             	    m["b"] = true;
               	    m["a"] = false;
               	    m["c"] = true;
@@ -167,7 +167,7 @@
 
                   ,"unordered_map_string_Rbyte"=list(
                    signature(),
-                   'std::tr1::unordered_map<std::string,Rbyte> m ;
+                   'RCPP_UNORDERED_MAP<std::string,Rbyte> m ;
 	            m["b"] = (Rbyte)0;
   	            m["a"] = (Rbyte)1;
   	            m["c"] = (Rbyte)2;
@@ -175,7 +175,7 @@
 
                   ,"unordered_map_string_string"=list(
                    signature(),
-                   'std::tr1::unordered_map<std::string,std::string> m ;
+                   'RCPP_UNORDERED_MAP<std::string,std::string> m ;
 	            m["b"] = "foo" ;
   	            m["a"] = "bar" ;
   	            m["c"] = "bling" ;
@@ -184,7 +184,7 @@
 
                   ,"unordered_map_string_generic"=list(
                    signature(),
-                   'std::tr1::unordered_map< std::string,std::vector<int> > m ;
+                   'RCPP_UNORDERED_MAP< std::string,std::vector<int> > m ;
 	            std::vector<int> b; b.push_back(1); b.push_back(2); m["b"] = b ;
   	            std::vector<int> a; a.push_back(1); a.push_back(2); a.push_back(2); m["a"] = a;
   	            std::vector<int> c; c.push_back(1); c.push_back(2); c.push_back(2); c.push_back(2); m["c"] = c;

Modified: pkg/Rcpp/src/RcppCommon.cpp
===================================================================
--- pkg/Rcpp/src/RcppCommon.cpp	2012-12-04 02:55:08 UTC (rev 4067)
+++ pkg/Rcpp/src/RcppCommon.cpp	2012-12-04 03:14:47 UTC (rev 4068)
@@ -36,7 +36,7 @@
 #else
 	LOGICAL(cap)[0] = FALSE ;
 #endif
-#ifdef HAS_INIT_LISTS
+#ifdef HAS_CXX0X_INITIALIZER_LIST
 	LOGICAL(cap)[1] = TRUE ;
 #else
 	LOGICAL(cap)[1] = FALSE ;



More information about the Rcpp-commits mailing list