From ripley at stats.ox.ac.uk  Thu Jan  5 05:21:05 2006
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Thu, 5 Jan 2006 04:21:05 +0000 (GMT)
Subject: [Rd] Using STL containers in R/C++
In-Reply-To: <200601050222.k052MSss030085@saturn.software.umn.edu>
References: <200601050222.k052MSss030085@saturn.software.umn.edu>
Message-ID: <Pine.LNX.4.61.0601050415570.27406@gannet.stats>

Using C++ will reduce portability of your code.  Using C++'s STL (not R's 
stl, so it is a good idea to spell out jargon) will reduce the 
portability further.

R itself does not use C++, and although a C++ compiler is found, it is 
only very mininally tested (and in particular its headers and libraries 
are not checked).  Some of us have only rather old C++ compilers on 
commercial Unixen.

On Wed, 4 Jan 2006, Andrew Finley wrote:

> Hi All,
> I am in the process of writing an R extension in c++ and am using several
> STL containers  (e.g., vector<double>, map<int, double>, multimap<int,
> double>).  I make sure to clear all these containers at the end of the
> .Call.   Everything compiles and runs just fine, but I'm a bit worried
> since I haven't found any other packages that use STL.
>
> So, my question: is it OK to use the STL containers in my code?  Will the
> use of this library somehow limit portability of this package? Or cause
> memory management problems?
>
> Thanks-
> Andy
>
>
> Andrew Finley, Research Fellow
> Department of Forest Resources
> College of Natural Resources
> University of Minnesota
> 305 Green Hall
> 1530 Cleveland Avenue N.
> St. Paul, MN 55108
>
> Ph 612-624-1714 office
> http://blue.fr.umn.edu/home
> www.cnr.umn.edu/FR/people/facstaff/finley/index.html
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] Using STL containers in R/C++
Prof Brian Ripley