[Rcpp-devel] __ambiguous_overload_for_operator[]
Kaveh Vakili
Kaveh.Vakili at ulb.ac.be
Sun Oct 31 20:04:28 CET 2010
thanks,
>You're mixing NumericVectors, std::vectors, and XPtrs, not to mention using plain C's memcpy to copy C++ objects. Even if it compiled, I'd be surprised if
this code worked correctly.
>
>If you want to copy pdA into v, you should probably use std::copy with iterators (with v as the target, not pdB). Telling v's constructor the size to pre-allocate would be good, too.
>
>Davor
>
>
>On 2010-10-27, at 3:22 PM, Kaveh Vakili wrote:
>
>> trying to feed the beast something line by line (if this works to the end it may become an instance of quickselect() :)
>>
>>
>> int k = Rcpp::as<int>(kr);
>> NumericVector pdA(pdAr);
>> int n = pdA.size();
>> //this:
>> //double *pdB = new double [n] ;
>> //becomes this?
>> std::vector<double>* v = new std::vector<double>;
>> Rcpp::XPtr< std::vector<double> > pdB(v) ;
>>
>> double dAx, dBuffer ;
>> int l = 0, lr = n - 1, jnc, j ;
>>
>> memcpy (pdB, pdA, n * sizeof (double)) ;
>>
>> while (l < lr){
>> dAx = pdB[k];
>>
>>
>> This last line gives:
>>
>>
>> filef9889ff.cpp:45: error: ambiguous overload for operator[] in pdB[k]
>>
>>
>> Also, i patched together the piece i found on the examples/tests so fare..probably a strange patchwork for you :)
>> _______________________________________________
>> Rcpp-devel mailing list
>> Rcpp-devel at lists.r-forge.r-project.org
>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>
>
>
More information about the Rcpp-devel
mailing list