[Rcpp-devel] is std::sort function broken??
Noah Silverman
noahsilverman at ucla.edu
Thu Sep 22 10:43:34 CEST 2011
Hi,
I have a vector of doubles that I want to sort.
Using Rcpp and inline. When attempting to create the function, I receive an error. Does anybody have any suggestions?
===================
Test <- cxxfunction(
signature(),
plugin="Rcpp", includes="#include <ctime>, #include <time.h>, #include <algorithm>. #include <vector>",
body="
std::vector<double> data;
for(int i=0; i != 20; i++){
data.push_back(i);
}
std::sort(data.front(), data.back());
return Rcpp::wrap(data);
"
)
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! /usr/include/c++/4.2.1/bits/stl_iterator_base_types.h: In instantiation of ‘std::iterator_traits<double>’:
/usr/include/c++/4.2.1/bits/stl_algo.h:2819: instantiated from ‘void std::sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = double]’
file6fb6ff92.cpp:36: instantiated from here
/usr/include/c++/4.2.1/bits/stl_iterator_base_types.h:129: error: ‘double’ is not a class, struct, or union type
/usr/include/c++/4.2.1/bits/stl_iterator_base_types.h:130: error: ‘double’ is not a class, struct, or union type
/usr/include/c++/4.2.1/bits/stl_iterator_base_types.h:131: error: ‘double’ is not a class, struct, or union type
/usr/include/c++/4.2.1/bits/stl_iterator_base_types.h:132: error: ‘double’ is not a class, struct, or union type
/usr/include/c++/4.2.1/bits/stl_iterator_base_types.h:133: error: ‘double’ is not a class, struct, or union type
/usr/include/c++/4.2.1/b
In addition: Warning message:
running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file6fb6ff92.cpp 2> file6fb6ff92.cpp.err.txt' had status 1
===========================
--
Noah Silverman
UCLA Department of Statistics
8117 Math Sciences Building #8208
Los Angeles, CA 90095
More information about the Rcpp-devel
mailing list