[Rcpp-devel] variadic templates

Dirk Eddelbuettel edd at debian.org
Sat Jan 2 22:17:19 CET 2010


On 2 January 2010 at 21:45, Romain François wrote:
| Hi,
| 
| they are really nice. they provide some sort of ellipsis in the template 
| argument.
| 
| unfortunately, they are not part of the current standard, but in the 
| forthcoming new standard c++0x. See 
| http://en.wikipedia.org/wiki/C%2B%2B0x#Variadic_templates
| 
| But, gcc has many of c++0x features covered. 
| http://gcc.gnu.org/projects/cxx0x.html
| 
| Why should we are about them. For example we want to mimic making this 
| call:
| 
|  > call( "rnorm", 10L, 0.0, 2.0 )
| rnorm(10L, 0, 2)
| 
| in C++, we (as soon as I can commit it) have the Language class, and I'd 
| like calling it something like :
| 
| Language obj( "rnorm", 10, 0.0, 2.0 ) ;
| 
| The wrap functions provide conversion of each element to a SEXP, and 
| variadic templates would take care of the rest.
| 
| This needs this in the Makevars :
| 
| PKG_CPPFLAGS += -I. -std=c++0x
| 
| and presumably also in RcppCxxFlags
| 
| 
| This is available as of GCC 4.3, so I guess we could #ifdef this somehow ?
| 
| Ideas ?

I am generally in favour. The damn C++ standard and C++ implementations move
glacially. Just recently I did toy with something at work -- it may just have
standard hash_map (or now: unordered_map) and I had three possibly setups:
Boost, C++'s tr1 which is still, and also the -stc++0x you suggest here.

However -- I know that I am for example a user of Rcpp in one setting where I
am forced to use a g++ 3.4.* vintage (!!).  So we shouldn't jump too early
and require ultra-modern compilers.

So that leaves us with #ifdef / configure logic which could be more work.
But if we shield it properly and don't break the old compilers / interfaces,
we can give it a shot.

Dirk

-- 
Three out of two people have difficulties with fractions.


More information about the Rcpp-devel mailing list