[Rcpp-devel] variadic templates

Romain François francoisromain at free.fr
Sun Jan 3 09:53:26 CET 2010


On 01/02/2010 10:17 PM, Dirk Eddelbuettel wrote:
>
> 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

I've commited. Currently using a CXX0X define in RcppCommon.h that is 
hardcoded. I hope someone can help me generate the define from configure.

Language obj( "rnorm", 10, 0.0, 2.0 ) ;

works like a charm

Romain

-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/IW9B : C++ exceptions at the R level
|- http://tr.im/IlMh : CPP package: exposing C++ objects
`- http://tr.im/HlX9 : new package : bibtex





More information about the Rcpp-devel mailing list